Ejemplo n.º 1
0
/*
Service: /GetMyAvatar
wParam=(char *)Buffer to file name
lParam=(int)Buffer size
return=0 on success, else on error
*/
INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
	TCHAR *buffer = (TCHAR*)wParam;
	int size = (int)lParam;

	debugLogA("[YahooGetMyAvatar]");

	if (buffer == NULL || size <= 0)
		return -1;

	if (!getByte("ShowAvatars", 1))
		return -2;

	DBVARIANT dbv;
	int ret = -3;

	if (getDword("AvatarHash", 0)) {
		if (!getTString("AvatarFile", &dbv)) {
			if (_taccess(dbv.ptszVal, 0) == 0) {
				mir_tstrncpy(buffer, dbv.ptszVal, size - 1);
				buffer[size - 1] = '\0';

				ret = 0;
			}
			db_free(&dbv);
		}
	}

	return ret;
}
Ejemplo n.º 2
0
static int findProfiles(TCHAR * szProfileDir, ENUMPROFILECALLBACK callback, LPARAM lParam)
{
	// find in Miranda IM profile subfolders
	HANDLE hFind = INVALID_HANDLE_VALUE;
	WIN32_FIND_DATA ffd;
	TCHAR searchspec[MAX_PATH];
	mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), szProfileDir);
	hFind = FindFirstFile(searchspec, &ffd);
	if ( hFind == INVALID_HANDLE_VALUE )
		return 0;

	do {
		// find all subfolders except "." and ".."
		if ( (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T("..")) ) {
			TCHAR buf[MAX_PATH], profile[MAX_PATH];
			mir_sntprintf(buf, SIZEOF(buf), _T("%s\\%s\\%s.dat"), szProfileDir, ffd.cFileName, ffd.cFileName);
			if (_taccess(buf, 0) == 0) {
				mir_sntprintf(profile, SIZEOF(profile), _T("%s.dat"), ffd.cFileName);
				if ( !callback(buf, profile, lParam ))
					break;
			}
		}
	}
		while ( FindNextFile(hFind, &ffd) );
	FindClose(hFind);

	return 1;
}
ConfigMgr::ConfigMgr(void) {
    // 读取配置文件
    CString& config = GetConfigFile();


    if (!config.IsEmpty()) {
        // 如果配置文件不存在,创建默认的配置文件
        if (0 != _taccess(config, 0)) {
            CLogMgr::Instance().AppendLog(LC_LOG_ERROR, _T("配置文件不存存在,创建默认配置文件"));

            static char s_default_config[] =
                "[system]\r\n"
                "access_key_id=\r\n"
                "secret_access_key=\r\n"
                "host=http://lss.bj.baidubce.com\r\n";

            CFile file;
            TRY {
                if (!file.Open(config, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite)) {
                    CLogMgr::Instance().AppendLog(LC_LOG_ERROR, _T("创建默认配置文件失败"));
                } else {
                    file.Write(s_default_config, sizeof(s_default_config));
                    file.Close();
                }
            }
            CATCH_ALL(e) {
                DELETE_EXCEPTION(e);
                CLogMgr::Instance().AppendLog(LC_LOG_ERROR, _T("创建默认配置文件异常"));
            }
            END_CATCH_ALL
        }
    } else {
Ejemplo n.º 4
0
void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, TCHAR* ptszDest, int cbLen)
{
	
	int tPathLen = mir_sntprintf(ptszDest, cbLen, TEXT("%s\\%S"), VARST( TEXT("%miranda_avatarcache%")), proto->m_szModuleName);
	if (_taccess(ptszDest, 0)) {
		int ret = CreateDirectoryTreeT(ptszDest);
		if (ret == 0)
			proto->debugLog(_T("getAvatarFilename(): Created new directory for avatar cache: %s."), ptszDest);
		else {
			proto->debugLog(_T("getAvatarFilename(): Can not create directory for avatar cache: %s. errno=%d: %s"), ptszDest, errno, strerror(errno));
			TCHAR buffer[512];
			mir_sntprintf(buffer, _countof(buffer), TranslateT("Cannot create avatars cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), ptszDest);
			PUShowMessageT(buffer, SM_WARNING);
		}
	}

	int format = PA_FORMAT_PNG;

	ptszDest[ tPathLen++ ] = '\\';
	if (item != NULL)
		format = item->avatarFormat;
	else if (proto->threadData != NULL)
		format = proto->threadData->avatarFormat;
	else
		format = db_get_dw(NULL, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN);

	const TCHAR *tszFileType = ProtoGetAvatarExtension(format);
	if ( item != NULL )
		mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S%s"), ptrA( TlenSha1(item->jid)), tszFileType);
	else
		mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S_avatar%s"), proto->m_szModuleName, tszFileType);
}
Ejemplo n.º 5
0
// returns 1 if a single profile (full path) is found within the profile dir
static int getProfile1(TCHAR * szProfile, size_t cch, TCHAR * profiledir, BOOL * noProfiles)
{
	unsigned int found = 0;

	if (IsInsideRootDir(profiledir, false))
		moveProfileDirProfiles(profiledir);
	moveProfileDirProfiles(profiledir, FALSE);

	bool nodprof = szProfile[0] == 0;
	bool reqfd = !nodprof && (_taccess(szProfile, 0) == 0 || shouldAutoCreate(szProfile));
	bool shpm = showProfileManager();

	if (reqfd)
		found++;

	if (shpm || !reqfd) {
		TCHAR searchspec[MAX_PATH];
		mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), profiledir);

		WIN32_FIND_DATA ffd;
		HANDLE hFind = FindFirstFile(searchspec, &ffd);
		if (hFind != INVALID_HANDLE_VALUE) {
			do {
				// make sure the first hit is actually a *.dat file
				if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T("..")))  {
					TCHAR newProfile[MAX_PATH];
					mir_sntprintf(newProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName);
					if (_taccess(newProfile, 0) == 0)
						if (++found == 1 && nodprof)
							_tcscpy(szProfile, newProfile);
				}
			}
				while (FindNextFile(hFind, &ffd));

			FindClose(hFind);
		}
		reqfd = !shpm && found == 1 && nodprof;
	}

	if ( noProfiles )
		*noProfiles = found == 0;

	if ( nodprof && !reqfd )
		szProfile[0] = 0;

	return reqfd;
}
Ejemplo n.º 6
0
static INT_PTR avSetAvatar(MCONTACT hContact, TCHAR *tszPath)
{
	TCHAR FileName[MAX_PATH];
	TCHAR *szFinalName;
	BYTE locking_request;

	if (hContact == NULL || fei == NULL)
		return 0;

	int is_locked = db_get_b(hContact, "ContactPhoto", "Locked", 0);

	if (tszPath == NULL) {
		OPENFILENAME ofn = { 0 };
		TCHAR filter[256];

		filter[0] = '\0';
		CallService(MS_UTILS_GETBITMAPFILTERSTRINGST, SIZEOF(filter), (LPARAM)filter);

		ofn.lStructSize = sizeof(ofn);
		ofn.hwndOwner = 0;
		ofn.lpstrFile = FileName;
		ofn.lpstrFilter = filter;
		ofn.nMaxFile = MAX_PATH;
		ofn.nMaxFileTitle = MAX_PATH;
		ofn.Flags = OFN_FILEMUSTEXIST | OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLESIZING | OFN_ENABLEHOOK;
		ofn.lpstrInitialDir = _T(".");
		*FileName = '\0';
		ofn.lpstrDefExt = _T("");
		ofn.hInstance = g_hInst;
		ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENSUBCLASS);
		ofn.lpfnHook = OpenFileSubclass;
		locking_request = is_locked;
		ofn.lCustData = (LPARAM)&locking_request;
		if (!GetOpenFileName(&ofn))
			return 0;

		szFinalName = FileName;
		is_locked = locking_request ? 1 : is_locked;
	}
	else szFinalName = tszPath;

	// filename is now set, check it and perform all needed action
	if (_taccess(szFinalName, 4) == -1)
		return 0;

	// file exists...
	TCHAR szBackupName[MAX_PATH];
	PathToRelativeT(szFinalName, szBackupName, g_szDataPath);
	db_set_ts(hContact, "ContactPhoto", "Backup", szBackupName);

	db_set_b(hContact, "ContactPhoto", "Locked", is_locked);
	db_set_ts(hContact, "ContactPhoto", "File", szFinalName);
	MakePathRelative(hContact, szFinalName);

	// Fix cache
	ChangeAvatar(hContact, true);
	return 0;
}
Ejemplo n.º 7
0
int LoadDatabaseModule(void)
{
	TCHAR szProfile[MAX_PATH];
	PathToAbsoluteT(_T("."), szProfile);
	_tchdir(szProfile);
	szProfile[0] = 0;

	LoadDatabaseServices();

	// find out which profile to load
	if (!getProfile(szProfile, SIZEOF(szProfile)))
		return 1;

	EnsureCheckerLoaded(false); // unload dbchecker

	if (arDbPlugins.getCount() == 0) {
		TCHAR buf[256];
		TCHAR* p = _tcsrchr(szProfile, '\\');
		mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda is unable to open '%s' because you do not have any profile plugins installed.\nYou need to install dbx_mmap.dll"), p ? ++p : szProfile);
		MessageBox(0, buf, TranslateT("No profile support installed!"), MB_OK | MB_ICONERROR);
	}

	// find a driver to support the given profile
	bool retry;
	int rc;
	do {
		retry = false;
		if ( _taccess(szProfile, 0) && shouldAutoCreate(szProfile))
			rc = tryCreateDatabase(szProfile);
		else
			rc = tryOpenDatabase(szProfile);

		if (rc > 0) {
			// if there were drivers but they all failed cos the file is locked, try and find the miranda which locked it
			if (fileExist(szProfile)) {
				// file isn't locked, just no driver could open it.
				TCHAR buf[256];
				TCHAR* p = _tcsrchr(szProfile, '\\');
				mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda was unable to open '%s', it's in an unknown format.\nThis profile might also be damaged, please run DbChecker which should be installed."), p ? ++p : szProfile);
				MessageBox(0, buf, TranslateT("Miranda can't understand that profile"), MB_OK | MB_ICONERROR);
			}
			else if (!FindMirandaForProfile(szProfile)) {
				TCHAR buf[256];
				TCHAR* p = _tcsrchr(szProfile, '\\');
				mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda was unable to open '%s'\nIt's inaccessible or used by other application or Miranda instance"), p ? ++p : szProfile);
				retry = MessageBox(0, buf, TranslateT("Miranda can't open that profile"), MB_RETRYCANCEL | MB_ICONERROR) == IDRETRY;
			}
		}
	}
		while (retry);

	if (rc == ERROR_SUCCESS) {
		InitIni();
		return 0;
	}

	return rc;
}
void CBCGPRibbonBackstagePagePrint::LoadPrinterImages()
{
	m_PrinterImages.Clear ();

	CString strPath;
    ::GetSystemDirectory(strPath.GetBuffer (_MAX_PATH + 1), _MAX_PATH);
	strPath.ReleaseBuffer ();

	if (strPath.IsEmpty ())
	{
		return;
	}

	if (strPath[strPath.GetLength () - 1] != TCHAR('\\'))
	{
		strPath += _T("\\");
	}

	// shell32.dll
	int uiImageShell32[] = {17, 168, 140, 169, 196, 197, 199, 198};
	int uiImageImageRes[] = {0, 0, 0, 0, 0, 0, 0, 0};
	if (_taccess(strPath + s_szImageres_DLL, 0) != -1)
	{
		// imageres.dll
		uiImageImageRes[0] = 51;
		uiImageImageRes[1] = 49;
		uiImageImageRes[2] = 53;
		uiImageImageRes[3] = 50;
		uiImageImageRes[4] = 76;
	}

	m_PrinterImages.SetImageSize (CSize(::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)), FALSE);

	for (int i = 0; i < 8; i++)
	{
		CString strFile;
		int nIconIndex = -1;
		if (uiImageImageRes[i] != 0)
		{
			nIconIndex = uiImageImageRes[i];
			strFile = strPath + s_szImageres_DLL;
		}
		else
		{
			nIconIndex = uiImageShell32[i];
			strFile = strPath + s_szShell32_DLL;
		}

		HICON hIcon = NULL;
		::ExtractIconEx(strFile, -nIconIndex, &hIcon, NULL, 1);
		if (hIcon != NULL)
		{
			m_PrinterImages.AddIcon (hIcon, TRUE);
			::DestroyIcon (hIcon);
		}
	}
}
Ejemplo n.º 9
0
void CMsnProto::MSN_GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext)
{
	size_t tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);

	if (_taccess(pszDest, 0))
		CreateDirectoryTreeT(pszDest);

	size_t tPathLen2 = tPathLen;
	if (hContact != NULL) {
		DBVARIANT dbv;
		if (getString(hContact, "PictContext", &dbv) == 0) {
			char* szAvatarHash = MSN_GetAvatarHash(dbv.pszVal);
			if (szAvatarHash != NULL) {
				TCHAR *sztAvatarHash = mir_a2t(szAvatarHash);
				tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s."), sztAvatarHash);
				mir_free(sztAvatarHash);
				mir_free(szAvatarHash);
			}
			else {
				delSetting(hContact, "PictContext");
				if (cbLen) pszDest[0] = 0;
			}
			db_free(&dbv);
		}
		else if (cbLen)
			pszDest[0] = 0;
	}
	else {
		TCHAR *sztModuleName = mir_a2t(m_szModuleName);
		tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s avatar."), sztModuleName);
		mir_free(sztModuleName);
	}

	if (ext == NULL) {
		mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("*"));

		bool found = false;
		_tfinddata_t c_file;
		long hFile = _tfindfirst(pszDest, &c_file);
		if (hFile > -1L) {
			do {
				if (_tcsrchr(c_file.name, '.')) {
					mir_sntprintf(pszDest + tPathLen2, cbLen - tPathLen2, _T("\\%s"), c_file.name);
					found = true;
				}
			}
				while(_tfindnext(hFile, &c_file) == 0);
			_findclose( hFile );
		}

		if (!found) pszDest[0] = 0;
	}
	else {
		tPathLen--;
		mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, ext);
	}
}
Ejemplo n.º 10
0
/*
================
rvGEApp::HandleCommandSave

Handles the ID_GUIED_FILE_SAVE and ID_GUIED_FILE_SAVEAS commands
================
*/
void rvGEApp::HandleCommandSave ( rvGEWorkspace* workspace, const char* filename )
{
    idStr realFilename;

    // See if we need to browse for a filename
    if ( workspace->IsNew ( ) || filename == NULL )
    {
        OPENFILENAME ofn;
        char		 szFile[MAX_PATH];

        strcpy ( szFile, workspace->GetFilename ( ) );

        // Initialize OPENFILENAME
        ZeroMemory(&ofn, sizeof(OPENFILENAME));
        ofn.lStructSize = sizeof(OPENFILENAME);
        ofn.hwndOwner = mMDIFrame;
        ofn.lpstrFile = szFile;
        ofn.nMaxFile = sizeof(szFile);
        ofn.lpstrFilter = "GUI Files\0*.GUI\0All Files\0*.*\0";
        ofn.nFilterIndex = 1;
        ofn.Flags = OFN_PATHMUSTEXIST;

        // Display the save dialog box.
        if ( !GetSaveFileName(&ofn) )
        {
            return;
        }

        realFilename = ofn.lpstrFile;
        realFilename.StripFileExtension ( );
        realFilename.Append ( ".gui" );

        // If the file already exists then warn about overwriting it
        if ( _taccess ( realFilename, 0 ) == 0 )
        {
            if ( IDNO == MessageBox ( va("File '%s' already exists. Do you want to replace it?", realFilename.c_str()), MB_YESNO|MB_ICONQUESTION ) )
            {
                return;
            }
        }
    }
    else
    {
        realFilename = filename;
    }

    // Now performe the file save
    if ( workspace->SaveFile ( realFilename ) )
    {
        mOptions.AddRecentFile ( workspace->GetFilename ( ) );
        UpdateRecentFiles ( );
    }
    else
    {
        MessageBox ( va("Could not write file '%s'", workspace->GetFilename()), MB_OK|MB_ICONERROR );
    }
}
Ejemplo n.º 11
0
std::vector<CStdStringA> BitmapUtil::GetLineCheckSum(LPCTSTR pszFileName)
{
	std::vector<CStdStringA> vLineCheckSum;
	int i(0);

	CStdString sPartialFile;
	if (_taccess(pszFileName, 6) != -1)
	{
		sPartialFile = pszFileName;
	}
	else
	{
		sPartialFile.Format(_T("%s%2.2d.bmp"), pszFileName, 0);
	}

	while (_taccess(sPartialFile.c_str(), 6) != -1)
	{
		BitmapUtil bmp;
		bmp.LoadIt(sPartialFile.c_str());

		if (bmp == NULL)
			return vLineCheckSum;
		BITMAP bmpInfo;
		if (::GetObject(bmp, sizeof(BITMAP), &bmpInfo) == 0)
			return vLineCheckSum;
		unsigned int byteSize = (bmpInfo.bmWidthBytes * bmpInfo.bmHeight);
		
		BYTE* buf = new BYTE [byteSize];
		int iBufSizeGetBitmapBits = GetBitmapBits(bmp, byteSize, buf);

		for (int j = 0; j < bmpInfo.bmHeight; ++j)
		{
			CString sMD5 = CMD5Checksum::GetMD5((BYTE*)&buf[j*bmpInfo.bmWidthBytes], bmpInfo.bmWidthBytes);
			vLineCheckSum.push_back(CStdString(sMD5));
		}

		delete [] buf;

		++i;
		sPartialFile.Format(_T("%s%2.2d.bmp"), pszFileName, i);
	}

	return vLineCheckSum;
}
Ejemplo n.º 12
0
LONG CuDlgSqlQueryPageXML::OnDisplayResult (WPARAM wParam, LPARAM lParam)
{
	CaSqlQuerySelectData* pData = (CaSqlQuerySelectData*)lParam;
	ASSERT (pData);
	if (!pData)
		return 0L;
	ASSERT (m_pQueryRowParam);
	if (!m_pQueryRowParam)
		return 0L;
	CWaitCursor waitCursor;
	try
	{
		CaSession* pCurrentSession = m_pQueryRowParam->GetSession();
		pCurrentSession->SetSessionNone();

		CString strTitle;
		strTitle.LoadString(IDS_TITLE_FETCHING_ROW);
#if defined (_ANIMATION_)
		CxDlgWait dlgWait(strTitle, NULL);
		dlgWait.SetDeleteParam(FALSE);
		dlgWait.SetExecParam (m_pQueryRowParam);
		dlgWait.SetUseAnimateAvi(AVI_FETCHR);
		dlgWait.SetUseExtraInfo();
		dlgWait.SetShowProgressBar(FALSE);
		dlgWait.SetHideCancelBottonAlways(TRUE);
		dlgWait.DoModal();
#else
		m_pQueryRowParam->Run();
#endif
		CuWebBrowser2* pIe = (CuWebBrowser2*)GetDlgItem (IDC_EXPLORER1);
		if (pIe && IsWindow (pIe->m_hWnd))
		{
			pIe->ShowWindow(SW_SHOW);
			CString strFile = m_bXMLSource? m_pQueryRowParam->GetFileXML(): m_pQueryRowParam->GetFileXSL();
			if (!strFile.IsEmpty() && _taccess(strFile, 0) == 0)
			{
				COleVariant vaURL(strFile);
				pIe->Navigate2 (vaURL, 0, NULL, NULL, NULL);
			}
		}
	}
	catch(CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	catch (CeSqlException e)
	{
		AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK);
	}
	catch (...)
	{
		AfxMessageBox (_T("CuDlgSqlQueryPageXML::OnDisplayResult: unknown error"));
	}
	return (LONG)0;
}
Ejemplo n.º 13
0
BOOL CuPropertyPageRestoreOption::CheckOverwriteBackupFile()
{
    CString strDir = m_strBackupFile.Left(m_strBackupFile.ReverseFind('\\'));
    if (_taccess(strDir, 0) != 0)
    {
        CString strMsg;
        AfxFormatString1(strMsg, IDS_MSG_DIR_NOACCESS, strDir);
        AfxMessageBox(strMsg);
        return FALSE;
    }

    if (_taccess(m_strBackupFile, 0) == 0)
    {
        int nAnswer = AfxMessageBox (IDS_MSG_OVERWRITE_BACKUPFILE, MB_ICONQUESTION|MB_YESNO);
        if (nAnswer != IDYES)
            return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 14
0
CStdStringW WordOutputProcessor::CleanUsingDOM(CStdStringW fileName)
{
	CStdStringW outFileName = fileName + L"_dom_cleaned.doc";
	if (_taccess(outFileName, 0) != 0)
	{
		DocumentCleaner::CleanUsingDOM(fileName, outFileName);

	}
	return outFileName;
}
Ejemplo n.º 15
0
BOOL CCarlaLanguage::open(LPCTSTR lpszPathName)
{
	CString sPath(lpszPathName);
	// this isn't needed since the calling methods make sure it is here
	if(!theApp.askUserToFindFileIfNotFound(sPath, CLangModelsDoc::getRegFileTypeID()))
		return FALSE;




	CSimpleProgressBar pb(_T(""));
	pb.SetTextEx(_T("Loading"), getName(), _T(" Lang File..."));

	USES_CONVERSION_U8;
	SFMFile *pFile = new SFMFile(T2CA(sPath), getCommentChar());
	if(!pFile->ensureOpen(_T("Language Document")))
		return FALSE;
	m_mfs.m_sCtrlFilesDirectory = getDirectory(sPath);

	// rename?
	if(::_tcsicmp(m_mfs.m_sCtrlFilesDirectory.Right(14), _T("Control Files\\")))
	{
		int len = m_mfs.m_sCtrlFilesDirectory.GetLength();
		CString sOldDirName = m_mfs.m_sCtrlFilesDirectory.Left(len-1);
		CString sNewDirName = m_mfs.m_sCtrlFilesDirectory.Left(1+len-_tcslen(_T("Files\\"))) + CONTROL_FOLDER_SUFFIX;

		if(-1 == _taccess(sNewDirName, 00))	// directory not found
		{
			CString s;
			s.Format(_T("This version of CarlaStudio uses a new name for the folder that contains control files.\n\nThe folder named %s will now be renamed to %s"),
						(LPCTSTR)sOldDirName, (LPCTSTR)sNewDirName);
			AfxMessageBox(s, MB_ICONINFORMATION   );
			if(0 == _taccess(m_mfs.m_sCtrlFilesDirectory, 00))	// is the dir of the old name there?
			{
				// rename it
				TRY
				{
					CFile::Rename( sOldDirName, sNewDirName );
				}
				CATCH( CFileException, e )
				{
					::checkForFileError(m_mfs.m_sCtrlFilesDirectory);
				}
void AppSettings::WriteSettings(Interface *gi)
{
	TCHAR iniName[MAX_PATH];
	GetIniFileName(iniName);
	if (-1 != _taccess(iniName, 0))
	{
		SetIniValue(Name.c_str(), TEXT("NiVersion"), NiVersion.c_str(), iniName);
		SetIniValue(Name.c_str(), TEXT("NiUserVersion"), FormatString(TEXT("%d"), NiUserVersion).c_str(), iniName);
		SetIniValue(Name.c_str(), TEXT("NiUserVersion2"), FormatString(TEXT("%d"), NiUserVersion2).c_str(), iniName);
	}
}
Ejemplo n.º 17
0
// move profile from profile subdir
static void moveProfileDirProfiles(TCHAR * profiledir, BOOL isRootDir = TRUE)
{
	TCHAR pfd[MAX_PATH];
	if (isRootDir) {
		TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_path%\\*.dat"));
		mir_sntprintf(pfd, SIZEOF(pfd), _T("%s"), path);
		mir_free(path);
	}
	else
		mir_sntprintf(pfd, SIZEOF(pfd), _T("%s\\*.dat"), profiledir);

	WIN32_FIND_DATA ffd;
	HANDLE hFind = FindFirstFile(pfd, &ffd);
	if (hFind != INVALID_HANDLE_VALUE)
	{
		TCHAR *c =_tcsrchr(pfd, '\\'); if (c) *c = 0;
		do
		{
			TCHAR path[MAX_PATH], path2[MAX_PATH];
			TCHAR* profile = mir_tstrdup(ffd.cFileName);
			TCHAR *c =_tcsrchr(profile, '.'); if (c) *c = 0;
			mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), pfd, ffd.cFileName);
			mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s"), profiledir, profile);
			CreateDirectoryTreeT(path2);
			mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s\\%s"), profiledir, profile, ffd.cFileName);
			if (_taccess(path2, 0) == 0)
			{
				const TCHAR tszMoveMsg[] =
					_T("Miranda is trying upgrade your profile structure.\n")
					_T("It cannot move profile %s to the new location %s\n")
					_T("Because profile with this name already exist. Please resolve the issue manually.");
				TCHAR buf[512];

				mir_sntprintf(buf, SIZEOF(buf), TranslateTS(tszMoveMsg), path, path2);
				MessageBox(NULL, buf, _T("Miranda IM"), MB_ICONERROR | MB_OK);
			}
			else if (MoveFile(path, path2) == 0)
			{
				const TCHAR tszMoveMsg[] =
					_T("Miranda is trying upgrade your profile structure.\n")
					_T("It cannot move profile %s to the new location %s automatically\n")
					_T("Most likely due to insufficient privileges. Please move profile manually.");
				TCHAR buf[512];

				mir_sntprintf(buf, SIZEOF(buf), TranslateTS(tszMoveMsg), path, path2);
				MessageBox(NULL, buf, _T("Miranda IM"), MB_ICONERROR | MB_OK);
				break;
			}
			mir_free(profile);
		}
		while(FindNextFile(hFind, &ffd));
	}
	FindClose(hFind);
}
Ejemplo n.º 18
0
INT_PTR CMsnProto::GetAvatar(WPARAM wParam, LPARAM lParam)
{
	TCHAR* buf = (TCHAR*)wParam;
	int  size = (int)lParam;

	if (buf == NULL || size <= 0)
		return -1;

	MSN_GetAvatarFileName(NULL, buf, size, NULL);
	return _taccess(buf, 0);
}
Ejemplo n.º 19
0
void CTestUtils::CheckForFileOrDirExistence(const CStdString& sPath)
{
	if (_taccess(sPath.c_str(), 0) == -1)
	{
		std::tstring sErr;
		sErr = _T("Expected test file / directory missing: ");
		sErr += sPath.c_str();
		
		_ASSERTE(_T("Expected test dir / file missing") == 0);
	}
}
Ejemplo n.º 20
0
/*---------------------------------------------------------------------------------------------
Name				:	ExistLocation(void)
Purpose				:	Return TRUE if the location exists
Parameters			:	None.
Return				:	Return TRUE if the location exists
Globals Modified	:	None.
--------------------------------------------------------------------------------------------*/
BOOL CPath::ExistLocation()
{
	if((_taccess(GetFolderPath(), 0)) == -1)
	{
		return(FALSE);
	}
	else
	{
		return(TRUE);
	}
}
Ejemplo n.º 21
0
bool LFSDMSHelper::DoesFileExist(const CStdString& sFileName)
{
	if (_taccess(sFileName, 0) != -1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
Ejemplo n.º 22
0
int ZipPlatform::FileExists(LPCTSTR lpszName)
{
	if (_taccess(lpszName, 0) == 0)
	{
		if (DirectoryExists(lpszName))
			return -1;
		return 1;
	}
	else
		return 0;

}
Ejemplo n.º 23
0
int LoadDatabaseModule(void)
{
	TCHAR szProfile[MAX_PATH];
	pathToAbsoluteT(_T("."), szProfile, NULL);
	_tchdir(szProfile);
	szProfile[0] = 0;

	// load the older basic services of the db
	InitUtils();

	// find out which profile to load
	if ( !getProfile( szProfile, SIZEOF( szProfile )))
		return 1;

	PLUGIN_DB_ENUM dbe;
	dbe.cbSize = sizeof(PLUGIN_DB_ENUM);
	dbe.lParam = (LPARAM)szProfile;

	if ( _taccess(szProfile, 0) && shouldAutoCreate( szProfile ))
		dbe.pfnEnumCallback=( int(*) (const char*,void*,LPARAM) )FindDbPluginAutoCreate;
	else
		dbe.pfnEnumCallback=( int(*) (const char*,void*,LPARAM) )FindDbPluginForProfile;

	// find a driver to support the given profile
	int rc = CallService(MS_PLUGINS_ENUMDBPLUGINS, 0, (LPARAM)&dbe);
	switch ( rc ) {
	case -1: {
		// no plugins at all
		TCHAR buf[256];
		TCHAR* p = _tcsrchr(szProfile,'\\');
		mir_sntprintf(buf,SIZEOF(buf),TranslateT("Miranda is unable to open '%s' because you do not have any profile plugins installed.\nYou need to install dbx_3x.dll or equivalent."), p ? ++p : szProfile );
		MessageBox(0,buf,TranslateT("No profile support installed!"),MB_OK | MB_ICONERROR);
		break;
	}
	case 1:
		// if there were drivers but they all failed cos the file is locked, try and find the miranda which locked it
		if (fileExist(szProfile)) {
			// file isn't locked, just no driver could open it.
			TCHAR buf[256];
			TCHAR* p = _tcsrchr(szProfile,'\\');
			mir_sntprintf(buf,SIZEOF(buf),TranslateT("Miranda was unable to open '%s', it's in an unknown format.\nThis profile might also be damaged, please run DB-tool which should be installed."), p ? ++p : szProfile);
			MessageBox(0,buf,TranslateT("Miranda can't understand that profile"),MB_OK | MB_ICONERROR);
		}
		else if (!FindMirandaForProfile(szProfile)) {
			TCHAR buf[256];
			TCHAR* p = _tcsrchr(szProfile,'\\');
			mir_sntprintf(buf,SIZEOF(buf),TranslateT("Miranda was unable to open '%s'\nIt's inaccessible or used by other application or Miranda instance"), p ? ++p : szProfile);
			MessageBox(0,buf,TranslateT("Miranda can't open that profile"),MB_OK | MB_ICONERROR);
		}
		break;
	}
	return (rc != 0);
}
Ejemplo n.º 24
0
		virtual ~CaLocalData()
		{
			while (!m_listObject.IsEmpty())
				delete m_listObject.RemoveHead();
			//
			// Prepare to delete the files (*.trl) outputed from AUDITDB:
			if (m_bLocal)
			{
				if (!m_strFile.IsEmpty() && (_taccess(m_strFile, 0) != -1))
					DeleteFile (m_strFile);
			}
		};
Ejemplo n.º 25
0
int KTestCommon::IsFileExists(const TCHAR* cpszFileName)
{
	int nResult  = false;
	int nRetCode = false;

	nRetCode = _taccess(cpszFileName, 0); // 第二个参数0表示文件是否存在
	KG_PROCESS_ERROR(nRetCode);

	nResult = true;
Exit0:
	return nResult;
}
Ejemplo n.º 26
0
void CMsnProto::MSN_GetCustomSmileyFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen, const char* SmileyName, int type)
{
	size_t tPathLen;

	InitCustomFolders();

	TCHAR* path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
	if (hCustomSmileyFolder == NULL || FoldersGetCustomPathT(hCustomSmileyFolder, path, (int)cbLen, _T(""))) {
		TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_userdata%"));
		TCHAR *tszModuleName = mir_a2t(m_szModuleName);
		tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%s\\CustomSmiley"), tmpPath, tszModuleName);
		mir_free(tszModuleName);
		mir_free(tmpPath);
	}
	else {
		_tcscpy(pszDest, path);
		tPathLen = _tcslen(pszDest);
	}

	if (hContact != NULL)
	{
		DBVARIANT dbv = {0};
		if (getTString(hContact, "e-mail", &dbv))
		{
			dbv.type = DBVT_ASCIIZ;
			dbv.ptszVal = (TCHAR*)mir_alloc(11);
			_ui64tot((UINT_PTR)hContact, dbv.ptszVal, 10);
		}

		tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s"), dbv.ptszVal);
		db_free(&dbv);
	}
	else {
		TCHAR *tszModuleName = mir_a2t(m_szModuleName);
		tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s"), tszModuleName);
		mir_free(tszModuleName);
	}

	bool exist = _taccess(pszDest, 0) == 0;

	if (type == 0) {
		if (!exist) pszDest[0] = 0;
		return;
	}

	if (!exist)
		CreateDirectoryTreeT(pszDest);

	TCHAR *sztSmileyName = mir_a2t(SmileyName);
	mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s.%s"), sztSmileyName,
		type == MSN_APPID_CUSTOMSMILEY ? _T("png") : _T("gif"));
	mir_free(sztSmileyName);
}
Ejemplo n.º 27
0
void TestLockDocument::TestLockAttachment()
{
	DocProviderWorker	objWorker;
	LockManager			docLock;
	CStdString			sDocID(DocumentID::GetDocProviderId() + TEST_DIRECTORY + TEST_DOC + _T(".doc"));
	DocumentID			docID(sDocID);
	CStdString			szDummyUser(_T("HighHouseShadow"));
	CStdString			sLockFileName(docID.GetLockFileName(szDummyUser, false));
	WSDocNonCom			wsDoc;

	objWorker.GetDocument(sDocID,NULL,wsDoc);
		
	HRESULT hrLock = docLock.CreateLock(sDocID, szDummyUser);

	if(FAILED(hrLock))
	{
		CStdString szErr;
		szErr.Format(_T("CreateLock returned a Failure Error code - %08x"),hrLock);
		assertMessage(false, szErr);
	}
	
	if (_taccess(sLockFileName, 0) == -1)
	{
		assertMessage(false, _T("We didn't create a lock file as HighHouseShadow"));
	}

	HRESULT hrUnlock = docLock.RemoveLock(sDocID,szDummyUser);
	
	if(FAILED(hrUnlock))
	{
		CStdString szErr;
		szErr.Format(_T("CreateLock returned a Failure Error code - %08x"),hrUnlock);
		assertMessage(false,szErr);
	}

	if (_taccess(sLockFileName, 0) != -1)
	{
		assertMessage(false, _T("We didn't remove the HighHouseShadow lock"));
	}
}
Ejemplo n.º 28
0
//return -1: user break;
//return 0: no error
//return 1: lpPath is invalid
//return 2: can not create lpPath
int CPathDialog::MakeSurePathExists(LPCTSTR lpPath)
{
	INXString strMsg;
	int iRet;
	try
	{
		//validate path
		iRet=Touch(lpPath, TRUE);
		if(iRet!=0)
		{
			throw iRet;
		}

		if(_taccess(lpPath, 0)==0)
		{
			return (int)0;
		}

		strMsg.Format(c_FolderDoesNotExist, lpPath);
		if(AfxMessageBox(strMsg, MB_YESNO|MB_ICONQUESTION) != IDYES)
		{
			return (int)-1;
		}

		//create path
		iRet=Touch(lpPath, FALSE);
		if(iRet!=0)
		{
			throw iRet; 
		}

		return 0;
	}
	catch(int nErrCode)
	{
		switch(nErrCode)
		{
		case 1:
			strMsg.Format(c_szErrInvalidPath, lpPath);
			break;
		case 2:
		default:
			strMsg.Format(c_szErrCreatePath, lpPath);
			break;
		}

		AfxMessageBox(strMsg, MB_OK|MB_ICONEXCLAMATION);

	}

	return iRet;
}
Ejemplo n.º 29
0
void CuDlgMain::InitializeCheckIOW()
{
	int nSel = CB_ERR;
	CStringArray arrayDB;
	CEdit* pEdit[2] = {&m_cEditFile1, &m_cEditFile2};
	CComboBoxEx* pArray[2] = {&m_cComboDatabase1, &m_cComboDatabase2};
	for (int i=0; i<2; i++)
	{
		if (pEdit[i]->IsWindowVisible())
		{
			CString strFile;
			pEdit[i]->GetWindowText(strFile);
			strFile.TrimLeft();
			strFile.TrimRight();
			if (!strFile.IsEmpty() && _taccess(strFile, 0) != -1)
			{
				int nInst = IsInstallationFile(strFile);
				if (nInst == 1)
					arrayDB.Add(_T(""));
				else
					arrayDB.Add(_T("???"));
			}
		}
		else
		{
			nSel = pArray[i]->GetCurSel();
			if (nSel != CB_ERR)
			{
				CaDatabase* pDatabase = (CaDatabase*)pArray[i]->GetItemDataPtr(nSel);
				if (pDatabase)
				{
					arrayDB.Add(pDatabase->GetItem());
				}
			}
		}
	}

	if (arrayDB.GetSize() == 2)
	{
		CString s1 = arrayDB[0];
		CString s2 = arrayDB[1];
		if (s1.IsEmpty() && s2.IsEmpty())
		{
			m_cCheckIgnoreOwner.ShowWindow (SW_SHOW);
		}
		else
		{
			m_cCheckIgnoreOwner.SetCheck(1);
			m_cCheckIgnoreOwner.ShowWindow (SW_HIDE);
		}
	}
}
Ejemplo n.º 30
0
bool facebook_client::save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc)
{
	NETLIBHTTPREQUEST req = {sizeof(req)};
	NETLIBHTTPREQUEST *resp;
	req.requestType = REQUEST_GET;
	req.szUrl = const_cast<char*>(url.c_str());
	req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT | NLHRF_NODUMP;
	req.nlc = nlc;

	resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
		reinterpret_cast<WPARAM>(this->parent->m_hNetlibUser), reinterpret_cast<LPARAM>(&req)));

	bool ret = false;

	if (resp) {
		nlc = resp->nlc;
		parent->debugLogA("@@@@@ Saving avatar URL %s to path %s", url.c_str(), _T2A(filename.c_str()));

		// Create folder if necessary
		std::tstring dir = filename.substr(0,filename.rfind('\\'));
		if (_taccess(dir.c_str(), 0))
			CreateDirectoryTreeT(dir.c_str());

		// Write to file
		FILE *f = _tfopen(filename.c_str(), _T("wb"));
		if (f != NULL) {
			fwrite(resp->pData,1,resp->dataLength,f);
			fclose(f);

			ret = _taccess(filename.c_str(), 0) == 0;
		}

		CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
	} else {
		nlc = NULL;
	}

	return ret;
}