-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDirectory.h
156 lines (138 loc) · 5.13 KB
/
CDirectory.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#pragma once
#include <windows.h>
#include <TChar.h>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#ifdef UNICODE
#ifndef TSTRING
#define TSTRING std::wstring
#endif
#else
#ifndef TSTRING
#define TSTRING std::string
#endif
#endif
#ifndef _WIN32_WCE
enum FileDeviceType // The type of disk partition
{
DISK_FIXED,
DISK_REMOVABLE,
CDROM
};
#endif
class CDirectory
{
public:
//-------------------------------------------------------------------------------------
//Description:
// Get directory's size
//
//Parameters:
// strPath: [in] The path of directory
//-------------------------------------------------------------------------------------
DWORD GetDirectorySize(const TSTRING &strPath);
//-------------------------------------------------------------------------------------
//Description:
// Check that the directory exists
//
//Parameters:
// strPath: [in] The path of directory
//-------------------------------------------------------------------------------------
BOOL CheckDirectoryExist(const TSTRING &strPath);
//-------------------------------------------------------------------------------------
//Description:
// Copy no empty directory to another directory
//
//Parameters:
// strDestinationPath: [in] The path of destination directory
// strSourcePath: [in] The path of source directory
//-------------------------------------------------------------------------------------
BOOL CopyDirectory(const TSTRING &strDestinationPath,const TSTRING &strSourcePath);
//-------------------------------------------------------------------------------------
//Description:
// Create the directory serial as to the path. For explame: If the path is "harddisk//test//temp",
//it will create the directory: "harddisk","test",and "temp".
//
//Parameters:
// strPath[in]: The path of the directory to be created
//--------------------------------------------------------------------------------------
void CreateDirectorySerial(const TSTRING &strPath);
//-------------------------------------------------------------------------------------
//Description:
// Delete the no empty directory
//
//Parameters:
// strPath: [in] The path of directory
//--------------------------------------------------------------------------------------
void DeleteDirectory(const TSTRING &strPath);
//-------------------------------------------------------------------------------------
//Description:
// Get the current runing path including '/' in last
//
//Parameters:
// pszPath: [out] Get the current path
// ulSize: [in] The size of the buffer. For example: szPath[MAX_NUMBER],the size if MAX_NUMBER.
//
//-------------------------------------------------------------------------------------
TCHAR *GetCurrentDirectory(TCHAR *pszPath, ULONG ulSize);
//---------------------------------------------------------------------
//Description:
// Find the file in the directory
//
//Parameters:
// DirectoryPath:[in] The path of directory.
// SuffixName: [in] To find the name of the suffix .if SuffixName is like TEXT("file.exe"),
// will find the path of all "file.exe".
// if SuffixName is like TEXT("*.exe"), will find the path of all file's Suffix is TEXT("exe").
// m_vFilePathList: [Out] Storage the path of file which to be found
//---------------------------------------------------------------------
BOOL FindFileFromDirectory(const TSTRING &DirectoryPath,const TSTRING &SuffixName,std::vector<TSTRING> &vFilePathList);
#ifndef _WIN32_WCE
//---------------------------------------------------------------------
//Description:
// Get disk partition
//
//Parameters:
// mDiskParition: [Out] Store disk partition'type
//
//---------------------------------------------------------------------
void GetDiskPartition(std::multimap<FileDeviceType,std::wstring> &mDiskParition);
#endif
protected:
//---------------------------------------------------------------------------
//Description:
// Find the string in the source string ,and return the position.
//
//Parameter:
// szSource:[in]
// The source string
// szFind:[in]
// The find string
// iBeginPos:[in]
// The begin finding position
//
//Return Values:
// If it -1 , couldn't find the string.
// Others , it's the position of the first character of szFind in the source string
//
//---------------------------------------------------------------------------
int FindString(const TCHAR *szSource, const TCHAR *szFind,const int iBeginPos);
//---------------------------------------------------------------------
//Description:
// Check the suffix of file name
//
//Parameters:
// FileName: [in] The file name to check
// SuffixName: [in] Special suffix name
//
//Return Value:
// TRUE -- The file is suitable
// FALSE -- The file is not suitable
//---------------------------------------------------------------------
BOOL CheckFileSuffix(const TSTRING &FileName,const TSTRING &SuffixName);
public:
CDirectory();
virtual ~CDirectory();
};