-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfolder.cpp
More file actions
51 lines (44 loc) · 1.41 KB
/
folder.cpp
File metadata and controls
51 lines (44 loc) · 1.41 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
50
51
#include "folder.hpp"
#include "mix.hpp"
FolderContent::FolderContent() {
size_t bufSize = ::Info.PanelControl(PANEL_ACTIVE, FCTL_GETPANELDIRECTORY, 0, nullptr);
FarPanelDirectory* dirInfo = reinterpret_cast<FarPanelDirectory*>(malloc(bufSize));
dirInfo->StructSize = sizeof(FarPanelDirectory);
::Info.PanelControl(PANEL_ACTIVE, FCTL_GETPANELDIRECTORY, bufSize, dirInfo);
dirName = std::wstring(dirInfo->Name);
free(dirInfo);
}
FolderContent::FolderContent(const std::wstring &dir) :
dirName(dir)
{
}
bool FolderContent::read() {
items.clear();
name2item.clear();
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(
(dirName + L"\\*.*").c_str(),
&fd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
PluginPanelItem ppi = {0};
ppi.CreationTime = fd.ftCreationTime;
ppi.LastAccessTime = fd.ftLastAccessTime;
ppi.LastWriteTime = fd.ftLastWriteTime;
ppi.FileSize = (unsigned long long)fd.nFileSizeLow |
(unsigned long long)fd.nFileSizeHigh << 32;
ppi.FileName = fd.cFileName;
ppi.AlternateFileName = fd.cAlternateFileName;
ppi.FileAttributes = fd.dwFileAttributes;
items.add(ppi);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
for (PluginPanelItems::const_iterator it = items.begin(); it != items.end(); ++it) {
const PluginPanelItem &ppi = *it;
name2item[ppi.FileName] = &ppi;
}
}
return true;
}