Exemple #1
0
HANDLE OpenLogFile()
{
	SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, g_szLogFileName);

	const TCHAR* szCompanyName = Zephyros::GetCompanyName();
	if (szCompanyName != NULL && szCompanyName[0] != TCHAR('\0'))
	{
		PathAddBackslash(g_szLogFileName);
		PathAppend(g_szLogFileName, szCompanyName);
		CreateDirectory(g_szLogFileName, NULL);
	}

	PathAddBackslash(g_szLogFileName);
	PathAppend(g_szLogFileName, Zephyros::GetAppName());
	CreateDirectory(g_szLogFileName, NULL);

	PathAppend(g_szLogFileName, TEXT("\\debug.log"));
	HANDLE hndLogFile = CreateFile(g_szLogFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hndLogFile == INVALID_HANDLE_VALUE)
	{
		//AppShowErrorMessage();
		hndLogFile = CreateFile(g_szLogFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
	}

	// write marker bytes to mark the file as UTF-8 encoded
	BYTE marker[] = { 0xef, 0xbb, 0xbf };
	DWORD dwBytesWritten = 0;
	WriteFile(hndLogFile, marker, 3, &dwBytesWritten, NULL);

	return hndLogFile;
}
bool CFileControlTool::InternalFindFile(LPCTSTR sFindPath, LPCTSTR sFindFileName, ULONGLONG &uCountFolder, ULONGLONG &uCountFile,PFINDFILE pCallbackFindFile,PFINDFOLDER pCallbackFindFolder,BOOL bFuzzy,BOOL bDirectory,PVOID pFileParameter,PVOID pDirectoryParameter)

{ 
	HANDLE hFind; 
	BOOL fFinished = FALSE; 
	WIN32_FIND_DATA FindFileData; 
	TCHAR sPath[MAX_PATH],sFormatFileName[MAX_PATH+3] = _T("*"); 

	lstrcpy(sFormatFileName, sFindPath); 

	if (bFuzzy){
		lstrcat(sFormatFileName,_T("\\*")); 
		lstrcat(sFormatFileName, sFindFileName); 
		lstrcat(sFormatFileName, _T("*")); 
	}else {
		PathAddBackslash(sFormatFileName);
		lstrcat(sFormatFileName,sFindFileName); 
	}

	hFind = FindFirstFile(sFormatFileName, &FindFileData); 

	if (hFind == INVALID_HANDLE_VALUE) { 
		return FALSE; 
	} else  { 
		while (!fFinished)  
		{ 
			lstrcpy(sPath, sFindPath); 
			PathAddBackslash(sPath);
			//lstrcat(sPath, _T("//")); 
			//PathAddExtension(sPath,FindFileData.cFileName);
			//lstrcat(sPath, FindFileData.cFileName); 

			if (FILE_ATTRIBUTE_DIRECTORY & FindFileData.dwFileAttributes) 
			{ 
				if (0 != lstrcmp(FindFileData.cFileName,_T(".")) && 0 != lstrcmp(FindFileData.cFileName,_T(".."))) {
					if(pCallbackFindFolder(sPath,FindFileData.cFileName,pDirectoryParameter))
						++uCountFolder;
				}
			} 
			else 
			{
				if(pCallbackFindFile(sPath,FindFileData.cFileName,pFileParameter))
					++uCountFile;
			}

			if (!FindNextFile(hFind, &FindFileData)) { 
				if (GetLastError() == ERROR_NO_MORE_FILES)  
					fFinished = TRUE;  
				else  
					break;
			} 
		} 

		FindClose(hFind); 
	} 

	return TRUE; 
} 
Exemple #3
0
BOOL RKLOG_API RKLSetLogPath(LPCTSTR pszLogPath)
{
	if (pszLogPath == NULL) {
		GetTempPath(sizeof(g_szLogPath), g_szLogPath);
		PathAddBackslash(g_szLogPath);
		lstrcat(g_szLogPath, "rklog\\");
	} else {
		lstrcpy(g_szLogPath, pszLogPath);
		PathAddBackslash(g_szLogPath);
	}

	return TRUE;
}
	tstring directory_str() const {
		TCHAR buf[MAX_PATH];
		memcpy(buf, this->buf, sizeof(this->buf));

		PathAddBackslash(buf);
		return buf;
	}
std::string getDirectory(){
	//filepath creatures
	char fileName[MAX_PATH];
	HINSTANCE hInstance = GetModuleHandle(NULL);
	GetModuleFileName(hInstance, fileName, MAX_PATH);

	char filePathAbs[MAX_PATH];
	//make absolute
	std::vector<int> slashes;
	int j =0;
	for(int i =0;i<MAX_PATH; i++){
		if(fileName[i]=='\\'){
			slashes.push_back(i);
		}
		if(fileName[i]=='.' && fileName[i+1]=='.' && fileName[i+2]=='\\'){
			slashes.pop_back();
			i++;
			j=slashes.back()+1;
			slashes.pop_back();
		}else{
			filePathAbs[j]=fileName[i];
			j++;
		}
	}

	PathRemoveFileSpec(filePathAbs);
	PathAddBackslash(filePathAbs);

	directory.clear();
	directory.append(filePathAbs);

	return directory;
}
CString CBase_AnalysisTemplate::GetDataFolder(enumPADATATYPENAME nDataType)
{
	TCHAR szOut[MAX_PATH];
	DWORD dwAttr;
	switch(nDataType) {
	case PA_DATATYPENAME_SAMPLE:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathSample);
		break;
	case PA_DATATYPENAME_TASK:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathTask);
		break;
	case PA_DATATYPENAME_COMPOUND:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathCompound);
		break;
	case PA_DATATYPENAME_METHOD:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathMethod);
		break;
	case PA_DATATYPENAME_CRYSTALREPORT:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathCrystalReport);
		break;
	case PA_DATATYPENAME_LOG:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathLog);
		break;
	case PA_DATATYPENAME_DATA:
	default:
		StrCpy(szOut, g_cConfigIni.CurrentSystem().m_szPathData);
	}

	dwAttr = GetFileAttributes(szOut);
	if (dwAttr == INVALID_FILE_ATTRIBUTES || !(dwAttr & FILE_ATTRIBUTE_DIRECTORY)) {
		SHCreateDirectory(NULL, szOut);
	}
	PathAddBackslash(szOut);
	return CString(szOut);
}
Exemple #7
0
static BOOL CreateFolder(LPCTSTR pszFolder)
{
	char *pszWork;

	pszWork = (char*)malloc(MAX_PATH);
	lstrcpy(pszWork, pszFolder);

	if (!PathFileExists(pszWork)) {
		if (PathIsRoot(pszWork)) {
			free(pszWork);
			return FALSE;
		}

		char *pszWork2;
		pszWork2 = (char *)malloc(MAX_PATH);
		lstrcpy(pszWork2, pszWork);
		PathAddBackslash(pszWork2);
		lstrcpy(pszWork2, "..");
		PathCanonicalize(pszWork, pszWork2);
		free(pszWork2);

		if (CreateFolder(pszWork)) {
			BOOL ret = CreateDirectory(pszFolder, NULL);
			free(pszWork);
			return ret;
		} else {
			free(pszWork);
			return FALSE;
		}
	}

	free(pszWork);

	return TRUE;
}
Exemple #8
0
/// Directory handling
/// ==================
BOOL md_dir_set(UINT32 dir_seg4, UINT16 dir_off) {

	CHAR dir_raw[MAX_PATH];
	TCHAR dir_ucs2[MAX_PATH];
	OEMCHAR *dos_dir;
	OEMCHAR *real_dir;
	BOOL ret;

	dos_dir = mem_read_sjis2ucs2(dir_raw, dir_ucs2, dir_seg4, dir_off, MAX_PATH);
	real_dir = md_drive_parse(dos_dir);
	
	// Changing to an empty string would lead to an error, crashing DOS
	if(real_dir[0] == _T('\0'))	{
		ret = 1;
	} else {
		ret = SetCurrentDirectory(real_dir);
	}
	// Don't set errors here!
	// Changing the registers quickly leads to
	// DOS crashing inside its own DIR function
	if(ret) {
		if(PathIsRelative(dos_dir)) {
			OEMCHAR tmp[MAX_PATH];
			lstrcpy(tmp, cur_dir);

			PathAddBackslash(tmp);
			lstrcat(tmp, real_dir);
			PathCanonicalize(cur_dir, tmp);
		} else {
			lstrcpy(cur_dir, real_dir);
		}
	}
	// Don't override DOS' handling of this one
	return FALSE;
}
Exemple #9
0
//絶対パスの取得
bool UtilGetAbsPathName(CString &_FullPath,LPCTSTR lpszFileName)
{
	ASSERT(lpszFileName&&_tcslen(lpszFileName)>0);
	if(!lpszFileName||_tcslen(lpszFileName)<=0){
		TRACE(_T("ファイル名が指定されていない\n"));
		return false;
	}

	//---絶対パス取得
	TCHAR szAbsPath[_MAX_PATH+1]={0};
	{
		TCHAR Buffer[_MAX_PATH+1]={0};	//ルートかどうかのチェックを行う
		_tcsncpy_s(Buffer,lpszFileName,_MAX_PATH);
		PathAddBackslash(Buffer);
		if(PathIsRoot(Buffer)){
			//ドライブ名だけが指定されている場合、
			//_tfullpathはそのドライブのカレントディレクトリを取得してしまう
			_tcsncpy_s(szAbsPath,lpszFileName,_MAX_PATH);
		}
		else if(!_tfullpath(szAbsPath,lpszFileName,_MAX_PATH)){
			TRACE(_T("絶対パス取得失敗\n"));
			return false;
		}
	}

	_FullPath=szAbsPath;
	return true;
}
Exemple #10
0
BOOL fileWalkOverPath(PSTR szPathIn,PSTR szPattern,BOOL bSubPath,PFN_WalkName WalkName,PVOID usrData)
{
  char            szWalkPath[_MAX_PATH];
  char            szWalkName[_MAX_PATH];
  BOOL            bCont;
  HANDLE          hFind;
  WIN32_FIND_DATA nData;
  
  bCont = TRUE;
  strcpy(szWalkPath,szPathIn);
  PathAddBackslash(szWalkPath);
  if (bSubPath){
    sprintf(szWalkName,"%s*.*",szWalkPath);
    if (INVALID_HANDLE_VALUE != (hFind=FindFirstFile(szWalkName,&nData))){
      do{
	    if (!FLAGON(nData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY)) continue;
	    if (0 == strcmp(nData.cFileName,".") || 0 == strcmp(nData.cFileName,"..")) continue;
	    strcpyV(szWalkName,sizeof(szWalkName),"%s%s\\",szWalkPath,nData.cFileName);
	    bCont = WalkName(usrData,szWalkPath,&nData) && fileWalkOverPath(szWalkName,szPattern,TRUE,WalkName,usrData);
      }while(bCont && FindNextFile(hFind,&nData));
      FindClose(hFind);
    }
  }
  strcpyV(szWalkName,sizeof(szWalkName),"%s%s",szWalkPath,szPattern);
  if (INVALID_HANDLE_VALUE != (hFind=FindFirstFile(szWalkName,&nData))){
	do{
	  if (0 == strcmp(nData.cFileName,".") || 0 == strcmp(nData.cFileName,"..")) continue;
      bCont = WalkName(usrData,szWalkPath,&nData);
	}while(bCont && FindNextFile(hFind,&nData));
	FindClose(hFind);
  }
  return bCont;
}
Exemple #11
0
//パスのディレクトリ部分だけを取り出す
void UtilPathGetDirectoryPart(CString &str)
{
	LPTSTR lpszBuf=str.GetBuffer(_MAX_PATH+1);
	PathRemoveFileSpec(lpszBuf);
	PathAddBackslash(lpszBuf);
	str.ReleaseBuffer();
}
Exemple #12
0
BOOL LocateComponent(LPCSTR lpszGameKey, LPCSTR lpszGameValue, LPCSTR lpszFileName, LPSTR lpszFilePath)
{
	assert(lpszGameKey);
	assert(lpszGameValue);
	assert(lpszFileName);

	BOOL bRetVal = FALSE;
	HKEY hAppRegKey;
	DWORD dwValueType, dwValueSize = MAX_PATH + 1;
	char szRegPath[MAX_PATH + 1];

	// This works almost identically to LocateGame, but this time we get the actual path of the game component
	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpszGameKey, 0, KEY_READ, &hAppRegKey) == ERROR_SUCCESS
		|| RegOpenKeyEx(HKEY_CURRENT_USER, lpszGameKey, 0, KEY_READ, &hAppRegKey) == ERROR_SUCCESS)
	{
		if (RegQueryValueEx(hAppRegKey, lpszGameValue, NULL, &dwValueType, (LPBYTE)&szRegPath, &dwValueSize) == ERROR_SUCCESS)
		{
			// Found the registry key. Append the file name to the directory.
			PathAddBackslash(szRegPath);
			strcat(szRegPath, lpszFileName);

			if (PathFileExists(szRegPath) && !PathIsDirectory(szRegPath))
				bRetVal = TRUE;
		}

		RegCloseKey(hAppRegKey);
	}

	if (lpszFilePath && bRetVal)
		strcpy(lpszFilePath, szRegPath);

	return bRetVal;
}
void CCheckDiskDlg::OnBnClickedCheck()
{
	CString strCheckDrv;
	for (int idx=0; idx<m_lstRigth.GetCount(); idx++)
	{
		CString str;
		m_lstRigth.GetText(idx, str);
		strCheckDrv += str[0];
	}
	if (strCheckDrv.IsEmpty())
	{
		AfxMessageBoxEx(TEXT("请选择您要进行检测修复的磁盘!"));
		return;
	}

	TCHAR szFilePath[MAX_PATH] = {0}, szParam[MAX_PATH] = {0};
	GetModuleFileName(NULL, szFilePath, MAX_PATH);
	PathRemoveFileSpec(szFilePath);
	PathAddBackslash(szFilePath);
	lstrcat(szFilePath, TEXT("EncipherC.exe"));
	lstrcat(szParam, TEXT("/SetChkdsk "));
	lstrcat(szParam, strCheckDrv);

	ShellExecute(NULL, TEXT("open"), szFilePath, szParam, TEXT(""), SW_SHOWNORMAL);
}
bool WorkingParameters::SetFTPInfo(LPCTSTR userName, LPCTSTR password)
{
	TCHAR configFilePath[MAX_PATH];
	GetModuleFileName(NULL, configFilePath, _countof(configFilePath));
	PathRemoveFileSpec(configFilePath);
	PathAddBackslash(configFilePath);
	_tcscat(configFilePath, _T("FTPCONFIG.ini"));

	TCHAR serverIP[128];
	GetPrivateProfileString(TEXT("Config"), TEXT("ServerIP"), NULL, serverIP, _countof(serverIP), configFilePath);
	int serverPort = GetPrivateProfileInt(TEXT("Config"), TEXT("ServerPort"), 21, configFilePath);

	FtpClient client;
	if (!client.Connect(serverIP, serverPort, userName, DecodePassword(password))) 
	{
		return false;
	}
	else
	{
		WritePrivateProfileString(TEXT("Config"), TEXT("User"), CodePassword(userName), configFilePath);
		WritePrivateProfileString(TEXT("Config"), TEXT("Password"), password, configFilePath);

		WritePrivateProfileString(TEXT("Upload"), TEXT("User"), CodePassword(userName), configFilePath);
		WritePrivateProfileString(TEXT("Upload"), TEXT("Password"), password, configFilePath);

		return true;
	}
}
Exemple #15
0
   /// <summary>Appends a trailing backslash if necessary</summary>
   /// <returns>New path with the trailing backslash</returns>
   Path  Path::AppendBackslash() const
   {
      CharArrayPtr buf( Copy() );

      // Supply copy of buffer
      PathAddBackslash(buf.get());
      return buf.get();
   }
Exemple #16
0
void LoadXinputDLL()
{
	LPVOID pReset = NULL;
    LPTSTR pFile = NULL;

    TCHAR path[MAX_PATH];
	TCHAR buffer[MAX_PATH];
    GetModuleFileName(hThis, path, MAX_PATH);
    PathRemoveFileSpec(path);
    PathAddBackslash(path);

	pFile = PathCombine(buffer,path,_T("xinput1_4.dll")); 
    if(pFile)
    {
        hXInput = LoadLibrary(pFile);
        pReset = GetProcAddress(hXInput,"reset");
        if(!pReset) FreeLibrary(hXInput);
    }

    pFile = PathCombine(buffer,path,_T("xinput1_3.dll")); 
    if(pFile)
    {
        hXInput = LoadLibrary(pFile);
        pReset = GetProcAddress(hXInput,"reset");
        if(!pReset) FreeLibrary(hXInput);
    }

    pFile = PathCombine(buffer,path,_T("xinput1_2.dll")); 
    if(pFile)
    {
        hXInput = LoadLibrary(pFile);
        pReset = GetProcAddress(hXInput,"reset");
        if(!pReset) FreeLibrary(hXInput);
    }

    pFile = PathCombine(buffer,path,_T("xinput1_1.dll")); 
    if(pFile)
    {
        hXInput = LoadLibrary(pFile);
        pReset = GetProcAddress(hXInput,"reset");
        if(!pReset) FreeLibrary(hXInput);
    }

    pFile = PathCombine(buffer,path,_T("xinput9_1_0.dll")); 
    if(pFile)
    {
        hXInput = LoadLibrary(pFile);
        pReset = GetProcAddress(hXInput,"reset");
        if(!pReset) FreeLibrary(hXInput);
    }

    if(!pReset)
    {
        pFile = PathCombine(buffer,path,_T("xinput9_1_0.dll")); 
        if(pFile) hXInput = LoadLibrary(pFile);

    }
}
void GetModuleFilePath(
	LPSTR pszDst,		/* [ou] パス格納先バッファ */
	DWORD dwSize)		/* [in] パス格納先バッファサイズ */
{
	ZeroMemory (pszDst, dwSize);
	GetModuleFileName (NULL, pszDst, dwSize);	/* モジュール名を取得 */
	PathRemoveFileSpec (pszDst);				/* ファイル名部分を消す */
	PathAddBackslash (pszDst);					/* 「\」を追加 */
}
Exemple #18
0
HRESULT CheckAccessPermissions()
{
    HRESULT                              hr = S_OK;
    CCriticalSection                     cs(&g_csInitClb);
    WCHAR                                pszTempDir[MAX_PATH+1];
    DWORD                                dwLen;

    if (g_bCheckedAccess)  {
        goto Exit;
    }

    hr = cs.Lock();
    if (FAILED(hr)) {
        goto Exit;
    }

    if (g_bCheckedAccess) {
        cs.Unlock();
        goto Exit;
    }

    StrCpy(pszTempDir, g_szWindowsDir);
    PathAddBackslash(pszTempDir);
    dwLen = lstrlenW(pszTempDir);

    while (1) {
        GetRandomName(pszTempDir + dwLen, TEMP_RANDOM_DIR_LENGTH); // create random dir of 15 chars.
        
        if (CreateDirectory(pszTempDir, NULL)) {
            g_CurrUserPermissions = READ_WRITE;
            g_GAC_AccessMode = READ_WRITE;
    
            if(!RemoveDirectory(pszTempDir))
            {
                // ASSERT(0); // oops we left a random  dir in winDir
            }

            break;
        }
        else {
            if (GetLastError() == ERROR_ALREADY_EXISTS) {
                continue;
            }

            hr = HRESULT_FROM_WIN32(GetLastError());
            break;
        }
        hr = S_OK;
    }

    g_bCheckedAccess = TRUE;
    cs.Unlock();
    
Exit:
    return hr;
}
Exemple #19
0
   /// <summary>Gets the folder portion of the path only</summary>
   /// <returns>Folder including a trailing backslash</returns>
   Path  Path::GetFolder() const
   {
      CharArrayPtr buf( Copy() );

      // Supply copy of buffer
      PathRemoveFileSpec(buf.get());
      PathAddBackslash(buf.get());

      return buf.get();
   }
HRESULT CChildFrame::_RecursionExtractData(LPCTSTR lpszRoot, HTREEITEM hCurrItem, CTreeViewCtrlEx * pTreeView) 
{ 
    HRESULT hr = S_OK; 
    CTreeItem tiCurr(hCurrItem, pTreeView); 
    TREE_ITEM_DATA * pTmp = (TREE_ITEM_DATA *)tiCurr.GetData(); 
    if (NULL == pTmp) { 
        return hr; 
    } 

    TCHAR szPathCopy[MAX_PATH] = { 0 }; 
    lstrcpyn(szPathCopy, lpszRoot, _countof(szPathCopy)); 

    PathAddBackslash(szPathCopy); 

    TCHAR szCurrName[MAX_PATH/2] = { 0 }; 
    tiCurr.GetText(szCurrName, _countof(szCurrName)); 
    AdjustFileName(szCurrName); 
    
    if (STGTY_STORAGE == pTmp->dwStgType) 
    { 
        TCHAR *pIter = szCurrName; 
        while (*pIter && pIter<szCurrName+lstrlen(szCurrName)) 
        { 
            if(*pIter == '.') { *pIter = '_'; } 
            pIter ++; 
        } 

        TCHAR szNowPath[MAX_PATH] = { 0 }; 
        wnsprintf(szNowPath, _countof(szNowPath), _T("%s%s"), szPathCopy, szCurrName); 
        ::SHCreateDirectoryEx(*pTreeView, szNowPath, NULL); 
    } 
    else if (STGTY_STREAM == pTmp->dwStgType)
    { 
        TCHAR szFileName[MAX_PATH] = { 0 }; 
        wnsprintf(szFileName, _countof(szFileName), _T("%s%s"), szPathCopy, szCurrName); 

        CComPtr<IStream> spFile; 
        hr = pTmp->spStgOrStrm->QueryInterface(&spFile); 
        if (FAILED(hr)) return hr; 

        hr = WriteStreamToFile(szFileName, spFile); 
    } 

    lstrcat(szPathCopy, szCurrName); 

    HTREEITEM hChild = tiCurr.GetChild(); 

    while (NULL != hChild) 
    { 
        _RecursionExtractData(szPathCopy, hChild, pTreeView); 
        hChild = CTreeItem(hChild, pTreeView).GetNextSibling(); 
    } 

    return hr; 
} 
Exemple #21
0
CFilePath &CFilePath::AddBackslash()
{
    if (GetLastChar(msPath) != gsBackslash)
    {
        CStringLock Buffer(msPath, msPath.GetLength()+1);

        PathAddBackslash(Buffer);
    }

    return *this;
}
Exemple #22
0
void fileSplitPathName(PSTR szFull,PSTR szPath,PSTR szName)
{
  int i;

  for(i=strlen(szFull)-1;i>=0;i--) if ('\\' == szFull[i]) break;
  strcpy(szPath,szFull);
  szPath[i+1] = 0;
  strcpy(szName,&szFull[i+1]);
  if (0 == szPath[0]) GetCurrentDirectory(_MAX_PATH,szPath);
  PathAddBackslash(szPath);
}
void CFileTreeView::RecordMemberVariable()
{
	_tcscpy(g_config.szFileManDir, m_Org.GetRootFolder().c_str());
	PathAddBackslash(g_config.szFileManDir);
	CRect rcWindow;
	GetWindowRect(&rcWindow);
	g_config.nFileManLeft = rcWindow.left;
	g_config.nFileManTop = rcWindow.top;
	g_config.nFileManWidth = rcWindow.Width();
	g_config.nFileManHeight = rcWindow.Height();
	g_config.WriteConfigToIni();
}
bool DebugLogger::Init() {
  LastErrorHolder errorHolder;

  GetAppDataPath(logPath_);
  PathAddBackslash(logPath_);
  _tcscat(logPath_, _T("log"));
  if (!CreateDirectoryRecusively(logPath_)) {
    errorHolder.SaveLastError();
    return false;
  }
 
  return true;
}
LRESULT ProgressDialog::OnUpgradeDone(WPARAM wParam, LPARAM lParam) {
  BOOL success = (BOOL)wParam;

  TCHAR appFilePath[MAX_PATH];
  _tcscpy(appFilePath, appDir_);
  PathAddBackslash(appFilePath);
  _tcscat(appFilePath, _T("ccmdbg.exe"));
  ShellExecute(NULL, NULL, appFilePath, _T("-skipupdate"), NULL, SW_SHOW);

  EndDialog(IDOK);

  return 0;
}
Exemple #26
0
BOOL
RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
{
    INFCONTEXT InfContext;
    BOOL res;
    WCHAR szName[MAX_PATH];
    WCHAR szPath[MAX_PATH];
    INT csidl;
    LPWSTR p;
    HMODULE hmod;
    HRESULT hret;

    /* Begin iterating the entries in the inf section */
    res = SetupFindFirstLine(hinf, szSection, NULL, &InfContext);
    if (!res) return FALSE;

    do
    {
        /* Get the name of the current type library */
        if (!SetupGetStringFieldW(&InfContext, 1, szName, MAX_PATH, NULL))
        {
            FatalError("SetupGetStringFieldW failed\n");
            continue;
        }

        if (!SetupGetIntField(&InfContext, 2, &csidl))
            csidl = CSIDL_SYSTEM;

        hret = SHGetFolderPathW(NULL, csidl, NULL, 0, szPath);
        if (FAILED(hret))
        {
            FatalError("SHGetFolderPathW failed hret=0x%d\n", hret);
            continue;
        }

        p = PathAddBackslash(szPath);
        _tcscpy(p, szName);

        hmod = LoadLibraryW(szName);
        if (hmod == NULL)
        {
            FatalError("LoadLibraryW failed\n");
            continue;
        }

        __wine_register_resources(hmod);

    }while (SetupFindNextLine(&InfContext, &InfContext));

    return TRUE;
}
tstring AppSettings::GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix) const
{
	TCHAR buffer[MAX_PATH];
	if (textureUseFullPath == 1) // full path name
	{
		GetFullPathName(fname, _countof(buffer), buffer, nullptr);
		return tstring(buffer);
	}
	else if (textureUseFullPath == -1) // only filename
	{
		return tstring(PathFindFileName(fname));
	}
	if (!PathIsRelative(fname))
	{
		TCHAR root[MAX_PATH];
		TCHAR file[MAX_PATH];
		GetFullPathName(fname, _countof(file), file, nullptr);
		PathMakePretty(file);

		for (tstringlist::const_iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
			GetFullPathName((*itr).c_str(), _countof(root), root, nullptr);
			PathAddBackslash(root);
			PathMakePretty(root);
			if (-1 != _taccess(root, 0)) {
				size_t len = _tcslen(root);
				if (0 == _tcsnicmp(root, file, len))
					return tstring(file + len);
			}
		}
	}
	else // Test if its relative to one of the specified root paths just return the texture 
	{
		for (tstringlist::const_iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
			PathCombine(buffer, itr->c_str(), fname);
			if (-1 != _taccess(buffer, 0)) {
				return fname;
			}
		}
	}

	// check if prefix is in place if so then just return fname as is
	for (LPCTSTR path = fname; path != nullptr; path = PathFindNextComponent(path))
	{
		if (_tcsnicmp(path, prefix, _tcslen(prefix)) == 0)
			return tstring(path);
	}

	// Now just combine prefix with file portion of the name
	PathCombine(buffer, prefix, PathFindFileName(fname));
	return tstring(buffer);
}
Exemple #28
0
BOOL bigfilehelper::GetDocumentPath(CString& strPath)
{
    BOOL retval;
    TCHAR szFilePath[MAX_PATH] = { 0 };

    retval = SHGetSpecialFolderPath(NULL, szFilePath, CSIDL_MYDOCUMENTS, FALSE);
    if (retval)
    {
        PathAddBackslash(szFilePath);
        strPath = szFilePath;
    }

    return retval;
}
Exemple #29
0
void TxSkin::enumSkins( IEnumSkinsCallBack* callback, LPCWSTR path, LPCWSTR iniFile )
{
	TCHAR pathBase[MAX_PATH];
	lstrcpy(pathBase, path);
	PathAddBackslash(pathBase);

	WIN32_FIND_DATA fd;
	TCHAR findMask[MAX_PATH];
	lstrcpy(findMask, path);
	lstrcat(findMask, TEXT("*"));

	HANDLE hFind = FindFirstFile(findMask, &fd);
	if(hFind != INVALID_HANDLE_VALUE)
	{
		do 
		{
			if(lstrcmp(fd.cFileName, TEXT(".")) && lstrcmp(fd.cFileName, TEXT("..")) && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				TCHAR shortPath[255];
				TCHAR skinFile[MAX_PATH];
				lstrcpy(skinFile, pathBase);
				lstrcat(skinFile, fd.cFileName);
				PathAddBackslash(skinFile);
				lstrcat(skinFile, iniFile);

				lstrcpy(shortPath, fd.cFileName);
				PathAddBackslash(shortPath);
				lstrcat(shortPath, iniFile);

				callback->onSkinFileFound(skinFile, shortPath);
			}
		} 
		while(FindNextFile(hFind, &fd));
		FindClose(hFind);
	}
}
bool WorkingParameters::LoadXML() {
  LastErrorHolder errorHolder;

  xmlDoc_.Release();

  HRESULT hr = xmlDoc_.CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER);
  if (FAILED(hr)) {
    errorHolder.SetError(ERROR_XML_COMPONENT_DAMAGE);
    return false;
  }

  TCHAR configFilePath[MAX_PATH];
  GetAppDataPath(configFilePath);
  PathAddBackslash(configFilePath);
  _tcscat(configFilePath, _T("config\\manifest.xml"));
  CComVariant varPath(configFilePath);
  VARIANT_BOOL successful;
  hr = xmlDoc_->load(varPath, &successful);
  if (FAILED(hr)) {
    errorHolder.SetError(ERROR_CONFIG_UNAVAILABLE);
    return false;
  }

  IXMLDOMElement *root = NULL;
  xmlDoc_->get_documentElement(&root);
  if (root == NULL) {
    errorHolder.SetError(ERROR_SERVER_CONFIG);
    return false;
  }
  
  Reset(root);

  ParameterBlock deviceBlock = SelectBlock(_T("Device"));
  if (deviceBlock.IsNull()) {
    errorHolder.SetError(ERROR_SERVER_CONFIG);
    return false;
  }

  currentModelParameters_ = deviceBlock.GetFirstChildBlock();
  if (currentModelParameters_.IsNull()) {
    errorHolder.SetError(ERROR_SERVER_CONFIG);
    return false;
  }
  currentModelId_ = currentModelParameters_.GetIntParameter(_T("id"), -1);

  return true;
}