-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathccdirectorywin32.h
73 lines (68 loc) · 2.82 KB
/
ccdirectorywin32.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
64
65
66
67
68
69
70
71
72
73
#pragma once
#include "platformconfig.h"
#if CCTARGET_PLATFORM == CCPLATFORM_WIN32
#include "ccdirectorystrategy.h"
#include <errno.h>
#include <io.h>
#include <direct.h>
#include <deque>
#include <stack>
struct FolderNode
{
std::string name;
FileAttributes nodeAttr;
bool hasDirectory = false;
std::vector<FolderNode>subChildren;
};
class CC_directory_win32 : public CC_directory_strategy
{
public:
void CreateDirectory(std::string path)override;
void RemoveDirectory(std::string path)override;
std::vector<std::string>GetSubDirectoriesCollection(std::string path)override;
std::vector<std::string> GetFiles(std::string path)override;
bool Exists(std::string path)override;
std::string GetCurrentDirectory()override;
std::string GetDirectoryRoot(std::string path)override;
void MoveDirectory(std::string sourcePath, std::string destPath)override;
void CopyDirectory(std::string sourcePath, std::string destPath)override;
void Search(std::string path, std::vector<std::string>& vec, std::string realSymbol)override;
void DisplayDirectoryInformation(std::string path)override;
void GetAccessControl(std::string path);
DateTime GetCreateTime(std::string path);
DateTime GetLastAccessTime(std::string path);
DateTime GetLastWriteTime(std::string path);
//************************************
// @Method: MoveDirectoryFast
// @Returns: void
// @Parameter: sourcePath
// @Parameter: destPath
// @Brief: 快速移动文件夹
//************************************
void MoveDirectoryFast(std::string sourcePath, std::string destPath);
void SetAccessControl(std::string path);
void SetCreateTime(DateTime);
void SetLastAccessTime(DateTime);
void SetLastWriteTime(DateTime);
void SetCurrentDirectory(std::string path);
void SetDateTime(DateTime&, struct tm*);
private:
std::vector<std::string>SearchFile(std::string path, bool recursive = false);
FolderNode GetOldCatalogTree(std::string path);
void ConstructNewCatalogTree(FolderNode node, std::string path, std::deque<std::string>& prefix);
void RemoveCatalogTree(FolderNode& node);
std::string GetRootDriveSymbol(int index);
void CopyFile(FolderNode& node, std::string sourcePath, std::string destPath);
void ParseOldCatalogTree(std::string path, std::vector<std::string>& treePath);
void ParseOldCatalogTree(std::string path, std::vector<std::string>& treePath, DirectoryInfo& d_info);
void SplitFilesAndDirectories(
std::vector<std::string>& originTree,
std::string& newPath, std::string& oldPath,
std::vector<std::string>&splitedOldFiles,
std::vector<std::string>&splitedNewDirectories,
std::vector<std::string>&splitedNewFiles);
void RebuildCatalogTree(std::vector<std::string>& newDirectory);
void CopyOriginFile(std::vector<std::string>& originFiles, std::vector<std::string>& newFiles);
void RemoveOldCatalogTree(std::vector<std::string>& originalPathTree);
};
#endif