00001
00002
00003
00004
00005 #ifndef __WINDOWS_FILEDIR_H
00006 #define __WINDOWS_FILEDIR_H
00007
00008 #include "String.h"
00009 #include "Defs.h"
00010
00011 namespace NWindows {
00012 namespace NFile {
00013 namespace NDirectory {
00014
00015 bool MyGetWindowsDirectory(CSysString &path);
00016 bool MyGetSystemDirectory(CSysString &path);
00017 #ifndef _UNICODE
00018 bool MyGetWindowsDirectory(UString &path);
00019 bool MyGetSystemDirectory(UString &path);
00020 #endif
00021
00022 inline bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
00023 { return BOOLToBool(::SetFileAttributes(fileName, fileAttributes)); }
00024 #ifndef _UNICODE
00025 bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
00026 #endif
00027
00028 inline bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
00029 { return BOOLToBool(::MoveFile(existFileName, newFileName)); }
00030 #ifndef _UNICODE
00031 bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
00032 #endif
00033
00034 inline bool MyRemoveDirectory(LPCTSTR pathName)
00035 { return BOOLToBool(::RemoveDirectory(pathName)); }
00036 #ifndef _UNICODE
00037 bool MyRemoveDirectory(LPCWSTR pathName);
00038 #endif
00039
00040 bool MyCreateDirectory(LPCTSTR pathName);
00041 bool CreateComplexDirectory(LPCTSTR pathName);
00042 #ifndef _UNICODE
00043 bool MyCreateDirectory(LPCWSTR pathName);
00044 bool CreateComplexDirectory(LPCWSTR pathName);
00045 #endif
00046
00047 bool DeleteFileAlways(LPCTSTR name);
00048 #ifndef _UNICODE
00049 bool DeleteFileAlways(LPCWSTR name);
00050 #endif
00051
00052 bool RemoveDirectoryWithSubItems(const CSysString &path);
00053 #ifndef _UNICODE
00054 bool RemoveDirectoryWithSubItems(const UString &path);
00055 #endif
00056
00057 #ifndef _WIN32_WCE
00058 bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
00059
00060 bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
00061 int &fileNamePartStartIndex);
00062 bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
00063 bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
00064 bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
00065 #ifndef _UNICODE
00066 bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
00067 int &fileNamePartStartIndex);
00068 bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
00069 bool GetOnlyName(LPCWSTR fileName, UString &resultName);
00070 bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName);
00071 #endif
00072
00073 inline bool MySetCurrentDirectory(LPCTSTR path)
00074 { return BOOLToBool(::SetCurrentDirectory(path)); }
00075 bool MyGetCurrentDirectory(CSysString &resultPath);
00076 #ifndef _UNICODE
00077 bool MySetCurrentDirectory(LPCWSTR path);
00078 bool MyGetCurrentDirectory(UString &resultPath);
00079 #endif
00080 #endif
00081
00082 bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
00083 CSysString &resultPath, UINT32 &filePart);
00084 #ifndef _UNICODE
00085 bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
00086 UString &resultPath, UINT32 &filePart);
00087 #endif
00088
00089 inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
00090 CSysString &resultPath)
00091 {
00092 UINT32 value;
00093 return MySearchPath(path, fileName, extension, resultPath, value);
00094 }
00095
00096 #ifndef _UNICODE
00097 inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
00098 UString &resultPath)
00099 {
00100 UINT32 value;
00101 return MySearchPath(path, fileName, extension, resultPath, value);
00102 }
00103 #endif
00104
00105 bool MyGetTempPath(CSysString &resultPath);
00106 #ifndef _UNICODE
00107 bool MyGetTempPath(UString &resultPath);
00108 #endif
00109
00110 UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
00111 #ifndef _UNICODE
00112 UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
00113 #endif
00114
00115 class CTempFile
00116 {
00117 bool _mustBeDeleted;
00118 CSysString _fileName;
00119 public:
00120 CTempFile(): _mustBeDeleted(false) {}
00121 ~CTempFile() { Remove(); }
00122 void DisableDeleting() { _mustBeDeleted = false; }
00123 UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
00124 bool Create(LPCTSTR prefix, CSysString &resultPath);
00125 bool Remove();
00126 };
00127
00128 #ifdef _UNICODE
00129 typedef CTempFile CTempFileW;
00130 #else
00131 class CTempFileW
00132 {
00133 bool _mustBeDeleted;
00134 UString _fileName;
00135 public:
00136 CTempFileW(): _mustBeDeleted(false) {}
00137 ~CTempFileW() { Remove(); }
00138 void DisableDeleting() { _mustBeDeleted = false; }
00139 UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
00140 bool Create(LPCWSTR prefix, UString &resultPath);
00141 bool Remove();
00142 };
00143 #endif
00144
00145 bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName);
00146
00147 class CTempDirectory
00148 {
00149 bool _mustBeDeleted;
00150 CSysString _tempDir;
00151 public:
00152 const CSysString &GetPath() const { return _tempDir; }
00153 CTempDirectory(): _mustBeDeleted(false) {}
00154 ~CTempDirectory() { Remove(); }
00155 bool Create(LPCTSTR prefix) ;
00156 bool Remove()
00157 {
00158 if (!_mustBeDeleted)
00159 return true;
00160 _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
00161 return (!_mustBeDeleted);
00162 }
00163 void DisableDeleting() { _mustBeDeleted = false; }
00164 };
00165
00166 #ifdef _UNICODE
00167 typedef CTempDirectory CTempDirectoryW;
00168 #else
00169 class CTempDirectoryW
00170 {
00171 bool _mustBeDeleted;
00172 UString _tempDir;
00173 public:
00174 const UString &GetPath() const { return _tempDir; }
00175 CTempDirectoryW(): _mustBeDeleted(false) {}
00176 ~CTempDirectoryW() { Remove(); }
00177 bool Create(LPCWSTR prefix) ;
00178 bool Remove()
00179 {
00180 if (!_mustBeDeleted)
00181 return true;
00182 _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
00183 return (!_mustBeDeleted);
00184 }
00185 void DisableDeleting() { _mustBeDeleted = false; }
00186 };
00187 #endif
00188
00189 }}}
00190
00191 #endif