-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDirUtils.h
63 lines (57 loc) · 1.16 KB
/
DirUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class DirUtils
{
public:
static BOOL FolderExist(CString strPath)
{
WIN32_FIND_DATA wfd;
BOOL rValue = FALSE;
HANDLE hFind = FindFirstFile(strPath, &wfd);
if ((hFind != INVALID_HANDLE_VALUE) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
rValue = TRUE;
}
FindClose(hFind);
return rValue;
}
static BOOL FileExist(CString strFileName)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strFileName, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
return false;
else
{
FindClose(hFind);
return true;
}
return false;
}
static CString getExeDirectory()
{
CString cstrDir;
TCHAR cBuffer[260];
GetCurrentDirectory(MAX_PATH, cBuffer);
CString cstrPath(cBuffer);
if (FolderExist(cstrPath + _T("\\symbols")))
{
cstrDir = cstrPath;
}
else
{
int nCount = cstrPath.ReverseFind(_T('\\'));
cstrPath.Delete(nCount, cstrPath.GetLength() - nCount);
if (FolderExist(cstrPath + _T("\\symbols")))
{
cstrDir = cstrPath;
}
else
{
MyMessageBox_Error(_T("getExeDirectory Error."), _T("Error"));
return _T("");
}
}
cstrDir += _T("\\");
return cstrDir;
}
};