forked from rutice/NicoJK
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathToolsCommon.h
More file actions
49 lines (46 loc) · 1.14 KB
/
Copy pathToolsCommon.h
File metadata and controls
49 lines (46 loc) · 1.14 KB
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
#pragma once
#ifdef _WIN32
#define NOMINMAX
#endif
#include "Common.h"
#ifndef _WIN32
#include <dirent.h>
#endif
struct LOGFILE_NAME {
TCHAR name[16];
};
template<class P>
void EnumLogFile(LPCTSTR dirPath, P enumProc)
{
#ifdef _WIN32
WIN32_FIND_DATA findData;
HANDLE hFind = FindFirstFile((tstring(dirPath) + TEXT("\\??????????.???")).c_str(), &findData);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 && _tcslen(findData.cFileName) == 14 &&
(!ComparePath(findData.cFileName + 10, TEXT(".txt")) ||
!ComparePath(findData.cFileName + 10, TEXT(".zip")))) {
LOGFILE_NAME n;
_tcscpy_s(n.name, findData.cFileName);
enumProc(n);
}
} while (FindNextFile(hFind, &findData));
FindClose(hFind);
}
#else
DIR *dir = opendir(dirPath);
if (dir) {
dirent *ent;
while (!!(ent = readdir(dir))) {
if (ent->d_type != DT_DIR && strlen(ent->d_name) == 14 &&
(!ComparePath(ent->d_name + 10, ".txt") ||
!ComparePath(ent->d_name + 10, ".zip"))) {
LOGFILE_NAME n;
strcpy(n.name, ent->d_name);
enumProc(n);
}
}
closedir(dir);
}
#endif
}