Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Windows/FileDir.h
3 #ifndef __WINDOWS_FILEDIR_H
4 #define __WINDOWS_FILEDIR_H
6 #include "../Common/String.h"
7 #include "Defs.h"
9 namespace NWindows {
10 namespace NFile {
11 namespace NDirectory {
13 bool MyGetWindowsDirectory(CSysString &path);
14 bool MyGetSystemDirectory(CSysString &path);
15 #ifndef _UNICODE
16 bool MyGetWindowsDirectory(UString &path);
17 bool MyGetSystemDirectory(UString &path);
18 #endif
20 inline bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
21 { return BOOLToBool(::SetFileAttributes(fileName, fileAttributes)); }
22 #ifndef _UNICODE
23 bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
24 #endif
26 inline bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
27 { return BOOLToBool(::MoveFile(existFileName, newFileName)); }
28 #ifndef _UNICODE
29 bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
30 #endif
32 inline bool MyRemoveDirectory(LPCTSTR pathName)
33 { return BOOLToBool(::RemoveDirectory(pathName)); }
34 #ifndef _UNICODE
35 bool MyRemoveDirectory(LPCWSTR pathName);
36 #endif
38 bool MyCreateDirectory(LPCTSTR pathName);
39 bool CreateComplexDirectory(LPCTSTR pathName);
40 #ifndef _UNICODE
41 bool MyCreateDirectory(LPCWSTR pathName);
42 bool CreateComplexDirectory(LPCWSTR pathName);
43 #endif
45 bool DeleteFileAlways(LPCTSTR name);
46 #ifndef _UNICODE
47 bool DeleteFileAlways(LPCWSTR name);
48 #endif
50 bool RemoveDirectoryWithSubItems(const CSysString &path);
51 #ifndef _UNICODE
52 bool RemoveDirectoryWithSubItems(const UString &path);
53 #endif
55 #ifndef _WIN32_WCE
56 bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
58 bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
59 int &fileNamePartStartIndex);
60 bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
61 bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
62 bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
63 #ifndef _UNICODE
64 bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
65 int &fileNamePartStartIndex);
66 bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
67 bool GetOnlyName(LPCWSTR fileName, UString &resultName);
68 bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName);
69 #endif
71 inline bool MySetCurrentDirectory(LPCTSTR path)
72 { return BOOLToBool(::SetCurrentDirectory(path)); }
73 bool MyGetCurrentDirectory(CSysString &resultPath);
74 #ifndef _UNICODE
75 bool MySetCurrentDirectory(LPCWSTR path);
76 bool MyGetCurrentDirectory(UString &resultPath);
77 #endif
78 #endif
80 bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
81 CSysString &resultPath, UINT32 &filePart);
82 #ifndef _UNICODE
83 bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
84 UString &resultPath, UINT32 &filePart);
85 #endif
87 inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
88 CSysString &resultPath)
89 {
90 UINT32 value;
91 return MySearchPath(path, fileName, extension, resultPath, value);
92 }
94 #ifndef _UNICODE
95 inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
96 UString &resultPath)
97 {
98 UINT32 value;
99 return MySearchPath(path, fileName, extension, resultPath, value);
100 }
101 #endif
103 bool MyGetTempPath(CSysString &resultPath);
104 #ifndef _UNICODE
105 bool MyGetTempPath(UString &resultPath);
106 #endif
108 UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
109 #ifndef _UNICODE
110 UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
111 #endif
113 class CTempFile
114 {
115 bool _mustBeDeleted;
116 CSysString _fileName;
117 public:
118 CTempFile(): _mustBeDeleted(false) {}
119 ~CTempFile() { Remove(); }
120 void DisableDeleting() { _mustBeDeleted = false; }
121 UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
122 bool Create(LPCTSTR prefix, CSysString &resultPath);
123 bool Remove();
124 };
126 #ifdef _UNICODE
127 typedef CTempFile CTempFileW;
128 #else
129 class CTempFileW
130 {
131 bool _mustBeDeleted;
132 UString _fileName;
133 public:
134 CTempFileW(): _mustBeDeleted(false) {}
135 ~CTempFileW() { Remove(); }
136 void DisableDeleting() { _mustBeDeleted = false; }
137 UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
138 bool Create(LPCWSTR prefix, UString &resultPath);
139 bool Remove();
140 };
141 #endif
143 bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName);
145 class CTempDirectory
146 {
147 bool _mustBeDeleted;
148 CSysString _tempDir;
149 public:
150 const CSysString &GetPath() const { return _tempDir; }
151 CTempDirectory(): _mustBeDeleted(false) {}
152 ~CTempDirectory() { Remove(); }
153 bool Create(LPCTSTR prefix) ;
154 bool Remove()
155 {
156 if (!_mustBeDeleted)
157 return true;
158 _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
159 return (!_mustBeDeleted);
160 }
161 void DisableDeleting() { _mustBeDeleted = false; }
162 };
164 #ifdef _UNICODE
165 typedef CTempDirectory CTempDirectoryW;
166 #else
167 class CTempDirectoryW
168 {
169 bool _mustBeDeleted;
170 UString _tempDir;
171 public:
172 const UString &GetPath() const { return _tempDir; }
173 CTempDirectoryW(): _mustBeDeleted(false) {}
174 ~CTempDirectoryW() { Remove(); }
175 bool Create(LPCWSTR prefix) ;
176 bool Remove()
177 {
178 if (!_mustBeDeleted)
179 return true;
180 _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
181 return (!_mustBeDeleted);
182 }
183 void DisableDeleting() { _mustBeDeleted = false; }
184 };
185 #endif
187 }}}
189 #endif