aduiVolumeDescriptor.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "adesk.h"
  13. #include "AdAChar.h"
  14. #pragma pack (push, 8)
  15. // This file is also built as part of the acdb dll separately from the rest of
  16. // AdUi. To do so, we can only use a part of MFC, so a little tweaking is
  17. // needed.
  18. //
  19. #ifdef ACUTIL_INTERNAL
  20. #include <tchar.h>
  21. #include <afx.h>
  22. #ifdef ADUI_PORT
  23. #undef ADUI_PORT
  24. #endif
  25. #ifdef ACCORE_BUILD
  26. #define ADUI_PORT __declspec(dllexport)
  27. #else
  28. #define ADUI_PORT
  29. #endif
  30. #endif
  31. #include "aduipathenums.h"
  32. // File system types.
  33. enum FS_TYPE {
  34. NOFS, // no media in drive (floppy, etc.)
  35. UKFS, // unknown, never heard of it!
  36. NTFS, // NT file system
  37. FAT, // DOS 8.3 file system
  38. VFAT, // Win95 LFN file system
  39. HPFS, // OS/2 File system
  40. CDFS, // ISO9660/High Sierra
  41. HFS, // Mac HFS volume type
  42. UFS // UNIX volume type
  43. };
  44. // Some oft used char constants for volume and file names
  45. extern __declspec(selectany) const ACHAR kBackslash = ACRX_T( '\\' );
  46. extern __declspec(selectany) const ACHAR kColon = ACRX_T( ':' );
  47. extern __declspec(selectany) const ACHAR kDoubleQuote= ACRX_T( '"' );
  48. extern __declspec(selectany) const ACHAR kEOS = ACRX_T( '\0' );
  49. extern __declspec(selectany) const ACHAR kPeriod = ACRX_T( '.' );
  50. extern __declspec(selectany) const ACHAR kSlash = ACRX_T( '/' );
  51. extern __declspec(selectany) const ACHAR kSpace = ACRX_T( ' ' );
  52. extern __declspec(selectany) const ACHAR kAsterisk = ACRX_T( '*' );
  53. extern __declspec(selectany) const ACHAR kQuestionmark = ACRX_T( '?' );
  54. extern __declspec(selectany) const ACHAR kZero = ACRX_T( '0' );
  55. /*******************************************************************
  56. The CAdUiVolumeDescriptor class is the base windows volume class.
  57. Derived classes corresponding to specific filesystem types are
  58. intended to perform the real work.
  59. *******************************************************************/
  60. class ADUI_PORT CAdUiVolumeDescriptor {
  61. friend class CAdUiPathname;
  62. public:
  63. // methods
  64. CAdUiVolumeDescriptor();
  65. CAdUiVolumeDescriptor(const CString&);
  66. virtual ~CAdUiVolumeDescriptor();
  67. /* return true if the volume is read-only, false otherwise */
  68. virtual inline BOOL CheckReadOnly() const {return m_d_readonly==1;};
  69. /* return true if the path is valid according to the rules of
  70. this volume type */
  71. virtual BOOL ValidateFilename( const CString*,
  72. const BOOL wildcard_ok = false ) const =0;
  73. /* validate a segment of a filename */
  74. virtual BOOL ValidateSegment( const CString*,
  75. const BOOL wildcard_ok = false ) const =0;
  76. // Return true if the filesystem is case_sensitive. Note that
  77. // we're talking about strict case sensitivity, as in Unix.
  78. virtual BOOL IsCaseSensitive(void) const;
  79. // Return true if the filesystem preserves case (like FAT, FAT32
  80. // and NTFS).
  81. virtual BOOL PreservesCase(void) const;
  82. // Return true if the filesystem "allows case sensitive lookup".
  83. // This is the Win32 FS_CASE_SENSITIVE bit. It's not clear
  84. // how useful this is, but whatever...
  85. virtual BOOL AllowsCaseSensitiveLookup(void) const;
  86. /* convert the string to the upper case if the volume is not
  87. case sensitive */
  88. virtual void VolCase( CString& ) const;
  89. /* return true if the strings match according to volume
  90. rules on case */
  91. virtual BOOL VolMatch( const ACHAR * a, const CString* b ) const;
  92. virtual BOOL VolMatch( const CString* a, const CString* b) const;
  93. /* return the local drive letter or volume name in the format
  94. required to build complete path strings */
  95. virtual inline const CString* GetLocalName() const { return m_vol_localname;};
  96. /* return the free space on this volume in units of 1024 bytes.
  97. As a general rule, if the available space exceeds 2 terabytes,
  98. return -1. */
  99. virtual LONG GetVolFreeSpace() const;
  100. /* check for available free space; i.e. return true if the
  101. specified number of bytes is available on this drive; I
  102. think it's safe to assume we won't be creating files
  103. larger than 4 Gbytes for quite a while. */
  104. virtual BOOL WillFit(DWORD) const;
  105. /* return true if the volume is still valid; i.e. if the network
  106. connection is still ok, if the same cd-rom is in the drive,
  107. etc. Obviously a NO-OP for a fixed disk. */
  108. virtual BOOL VolumeValid() const;
  109. #ifdef _DEBUG
  110. /* a debugging function to dump the contents of the volume
  111. descriptor in some human readable format */
  112. virtual void debug_dump(FILE*) const;
  113. #endif
  114. inline BOOL IsRemote() const { return m_d_remote == 1; }
  115. inline BOOL IsRemovable() const { return m_d_removable == 1; }
  116. protected:
  117. void GetConnectionName( void );
  118. // To be removed in future release. Just use CString::Find()
  119. int Find(const CString& str, UINT ch) const;
  120. int IsControl(int c) const;
  121. // data elements
  122. /* the filesystem type for the drive */
  123. FS_TYPE m_vol_fs_type;
  124. /* flags for drive characteristics */
  125. typedef unsigned flagbits;
  126. flagbits m_d_fixed: 1;
  127. flagbits m_d_removable: 1;
  128. flagbits m_d_cdrom: 1;
  129. flagbits m_d_remote: 1;
  130. flagbits m_d_ramdisk: 1;
  131. flagbits m_d_readonly: 1;
  132. flagbits m_d_caseSensitive: 1;
  133. /* the local name for this volume */
  134. CString* m_vol_localname;
  135. /* the maximum length for any component of a path */
  136. int m_max_component_size;
  137. /* the maximum path length for this volume type */
  138. int m_max_path_length;
  139. /* The correct component separator for this volume type
  140. To be used in generating file references. For normal
  141. work the native UI syntax is always used. */
  142. ACHAR m_vol_slash;
  143. BOOL mbUnused; // delete me - was m_amodeMultiByte
  144. DWORD m_vol_serial;
  145. DWORD m_fsflags;
  146. CString* m_vol_label;
  147. CString* m_connection_name;
  148. const ACHAR * m_doubleslash;
  149. };
  150. class ADUI_PORT CAdUiNTFSVolumeDescriptor : public CAdUiVolumeDescriptor {
  151. public:
  152. CAdUiNTFSVolumeDescriptor(const CString&);
  153. ~CAdUiNTFSVolumeDescriptor(){};
  154. BOOL ValidateFilename( const CString*,
  155. const BOOL wildcard_ok = false ) const;
  156. BOOL ValidateSegment( const CString*,
  157. const BOOL wildcard_ok = false ) const;
  158. };
  159. class ADUI_PORT CAdUiVFATVolumeDescriptor : public CAdUiVolumeDescriptor {
  160. public:
  161. CAdUiVFATVolumeDescriptor(const CString&);
  162. ~CAdUiVFATVolumeDescriptor(){};
  163. BOOL ValidateFilename( const CString*,
  164. const BOOL wildcard_ok = false ) const;
  165. BOOL ValidateSegment( const CString*,
  166. const BOOL wildcard_ok = false ) const;
  167. };
  168. class ADUI_PORT CAdUiHPFSVolumeDescriptor : public CAdUiVolumeDescriptor {
  169. public:
  170. CAdUiHPFSVolumeDescriptor(const CString&);
  171. ~CAdUiHPFSVolumeDescriptor(){};
  172. BOOL ValidateFilename( const CString*,
  173. const BOOL wildcard_ok = false ) const;
  174. BOOL ValidateSegment( const CString*,
  175. const BOOL wildcard_ok = false ) const;
  176. };
  177. class ADUI_PORT CAdUiCDFSVolumeDescriptor : public CAdUiVolumeDescriptor {
  178. public:
  179. CAdUiCDFSVolumeDescriptor(const CString&);
  180. ~CAdUiCDFSVolumeDescriptor(){};
  181. BOOL ValidateFilename( const CString*,
  182. const BOOL wildcard_ok = false ) const;
  183. BOOL ValidateSegment( const CString*,
  184. const BOOL wildcard_ok = false ) const;
  185. };
  186. class ADUI_PORT CAdUiFATVolumeDescriptor : public CAdUiVolumeDescriptor {
  187. public:
  188. CAdUiFATVolumeDescriptor(const CString&);
  189. ~CAdUiFATVolumeDescriptor(){};
  190. BOOL ValidateFilename( const CString*,
  191. const BOOL wildcard_ok = false ) const;
  192. BOOL ValidateSegment( const CString*,
  193. const BOOL wildcard_ok = false ) const;
  194. protected:
  195. int m_segc;
  196. };
  197. class ADUI_PORT CAdUiUFSVolumeDescriptor : public CAdUiVolumeDescriptor {
  198. public:
  199. CAdUiUFSVolumeDescriptor(const CString&);
  200. ~CAdUiUFSVolumeDescriptor(){};
  201. BOOL ValidateFilename( const CString*,
  202. const BOOL wildcard_ok = false ) const;
  203. BOOL ValidateSegment( const CString*,
  204. const BOOL wildcard_ok = false ) const;
  205. };
  206. class ADUI_PORT CAdUiNOFSVolumeDescriptor : public CAdUiVolumeDescriptor {
  207. public:
  208. CAdUiNOFSVolumeDescriptor(const CString&);
  209. ~CAdUiNOFSVolumeDescriptor(){};
  210. BOOL ValidateFilename( const CString*,
  211. const BOOL wildcard_ok = false ) const;
  212. BOOL ValidateSegment( const CString*,
  213. const BOOL wildcard_ok = false ) const;
  214. };
  215. #pragma pack (pop)