diff src/win32/7zip/7z/CPP/Windows/FileDir.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/Windows/FileDir.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,178 @@
     1.4 +// Windows/FileDir.h
     1.5 +
     1.6 +#ifndef __WINDOWS_FILEDIR_H
     1.7 +#define __WINDOWS_FILEDIR_H
     1.8 +
     1.9 +#include "../Common/MyString.h"
    1.10 +#include "Defs.h"
    1.11 +
    1.12 +namespace NWindows {
    1.13 +namespace NFile {
    1.14 +namespace NDirectory {
    1.15 +
    1.16 +#ifdef WIN_LONG_PATH
    1.17 +bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2);
    1.18 +#endif
    1.19 +
    1.20 +bool MyGetWindowsDirectory(CSysString &path);
    1.21 +bool MyGetSystemDirectory(CSysString &path);
    1.22 +#ifndef _UNICODE
    1.23 +bool MyGetWindowsDirectory(UString &path);
    1.24 +bool MyGetSystemDirectory(UString &path);
    1.25 +#endif
    1.26 +
    1.27 +bool SetDirTime(LPCWSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
    1.28 +
    1.29 +bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes);
    1.30 +bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName);
    1.31 +bool MyRemoveDirectory(LPCTSTR pathName);
    1.32 +bool MyCreateDirectory(LPCTSTR pathName);
    1.33 +bool CreateComplexDirectory(LPCTSTR pathName);
    1.34 +bool DeleteFileAlways(LPCTSTR name);
    1.35 +bool RemoveDirectoryWithSubItems(const CSysString &path);
    1.36 +
    1.37 +#ifndef _UNICODE
    1.38 +bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
    1.39 +bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
    1.40 +bool MyRemoveDirectory(LPCWSTR pathName);
    1.41 +bool MyCreateDirectory(LPCWSTR pathName);
    1.42 +bool CreateComplexDirectory(LPCWSTR pathName);
    1.43 +bool DeleteFileAlways(LPCWSTR name);
    1.44 +bool RemoveDirectoryWithSubItems(const UString &path);
    1.45 +#endif
    1.46 +
    1.47 +#ifndef _WIN32_WCE
    1.48 +bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
    1.49 +
    1.50 +bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
    1.51 +    int &fileNamePartStartIndex);
    1.52 +bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
    1.53 +bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
    1.54 +bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
    1.55 +#ifndef _UNICODE
    1.56 +bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
    1.57 +    int &fileNamePartStartIndex);
    1.58 +bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
    1.59 +bool GetOnlyName(LPCWSTR fileName, UString &resultName);
    1.60 +bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName);
    1.61 +#endif
    1.62 +
    1.63 +inline bool MySetCurrentDirectory(LPCTSTR path)
    1.64 +  { return BOOLToBool(::SetCurrentDirectory(path)); }
    1.65 +bool MyGetCurrentDirectory(CSysString &resultPath);
    1.66 +#ifndef _UNICODE
    1.67 +bool MySetCurrentDirectory(LPCWSTR path);
    1.68 +bool MyGetCurrentDirectory(UString &resultPath);
    1.69 +#endif
    1.70 +#endif
    1.71 +
    1.72 +bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
    1.73 +  CSysString &resultPath, UINT32 &filePart);
    1.74 +#ifndef _UNICODE
    1.75 +bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
    1.76 +  UString &resultPath, UINT32 &filePart);
    1.77 +#endif
    1.78 +
    1.79 +inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
    1.80 +  CSysString &resultPath)
    1.81 +{
    1.82 +  UINT32 value;
    1.83 +  return MySearchPath(path, fileName, extension, resultPath, value);
    1.84 +}
    1.85 +
    1.86 +#ifndef _UNICODE
    1.87 +inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
    1.88 +  UString &resultPath)
    1.89 +{
    1.90 +  UINT32 value;
    1.91 +  return MySearchPath(path, fileName, extension, resultPath, value);
    1.92 +}
    1.93 +#endif
    1.94 +
    1.95 +bool MyGetTempPath(CSysString &resultPath);
    1.96 +#ifndef _UNICODE
    1.97 +bool MyGetTempPath(UString &resultPath);
    1.98 +#endif
    1.99 +
   1.100 +UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
   1.101 +#ifndef _UNICODE
   1.102 +UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
   1.103 +#endif
   1.104 +
   1.105 +class CTempFile
   1.106 +{
   1.107 +  bool _mustBeDeleted;
   1.108 +  CSysString _fileName;
   1.109 +public:
   1.110 +  CTempFile(): _mustBeDeleted(false) {}
   1.111 +  ~CTempFile() { Remove(); }
   1.112 +  void DisableDeleting() { _mustBeDeleted = false; }
   1.113 +  UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
   1.114 +  bool Create(LPCTSTR prefix, CSysString &resultPath);
   1.115 +  bool Remove();
   1.116 +};
   1.117 +
   1.118 +#ifdef _UNICODE
   1.119 +typedef CTempFile CTempFileW;
   1.120 +#else
   1.121 +class CTempFileW
   1.122 +{
   1.123 +  bool _mustBeDeleted;
   1.124 +  UString _fileName;
   1.125 +public:
   1.126 +  CTempFileW(): _mustBeDeleted(false) {}
   1.127 +  ~CTempFileW() { Remove(); }
   1.128 +  void DisableDeleting() { _mustBeDeleted = false; }
   1.129 +  UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
   1.130 +  bool Create(LPCWSTR prefix, UString &resultPath);
   1.131 +  bool Remove();
   1.132 +};
   1.133 +#endif
   1.134 +
   1.135 +bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName);
   1.136 +
   1.137 +class CTempDirectory
   1.138 +{
   1.139 +  bool _mustBeDeleted;
   1.140 +  CSysString _tempDir;
   1.141 +public:
   1.142 +  const CSysString &GetPath() const { return _tempDir; }
   1.143 +  CTempDirectory(): _mustBeDeleted(false) {}
   1.144 +  ~CTempDirectory() { Remove();  }
   1.145 +  bool Create(LPCTSTR prefix) ;
   1.146 +  bool Remove()
   1.147 +  {
   1.148 +    if (!_mustBeDeleted)
   1.149 +      return true;
   1.150 +    _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
   1.151 +    return (!_mustBeDeleted);
   1.152 +  }
   1.153 +  void DisableDeleting() { _mustBeDeleted = false; }
   1.154 +};
   1.155 +
   1.156 +#ifdef _UNICODE
   1.157 +typedef CTempDirectory CTempDirectoryW;
   1.158 +#else
   1.159 +class CTempDirectoryW
   1.160 +{
   1.161 +  bool _mustBeDeleted;
   1.162 +  UString _tempDir;
   1.163 +public:
   1.164 +  const UString &GetPath() const { return _tempDir; }
   1.165 +  CTempDirectoryW(): _mustBeDeleted(false) {}
   1.166 +  ~CTempDirectoryW() { Remove();  }
   1.167 +  bool Create(LPCWSTR prefix) ;
   1.168 +  bool Remove()
   1.169 +  {
   1.170 +    if (!_mustBeDeleted)
   1.171 +      return true;
   1.172 +    _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
   1.173 +    return (!_mustBeDeleted);
   1.174 +  }
   1.175 +  void DisableDeleting() { _mustBeDeleted = false; }
   1.176 +};
   1.177 +#endif
   1.178 +
   1.179 +}}}
   1.180 +
   1.181 +#endif