Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
3.0 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // File: CDir.hxx
  4. //
  5. // Purpose: Declare the CDirectory class. Objects of this class
  6. // are used to represent a directory, and provide additional
  7. // information about it.
  8. //
  9. //+-----------------------------------------------------------------------
  10. #ifndef _C_DIR_HXX_
  11. #define _C_DIR_HXX_
  12. // --------
  13. // Includes
  14. // --------
  15. #include "CFMEx.hxx"
  16. // --------
  17. // Typedefs
  18. // --------
  19. // An enumeration of the possible file system types.
  20. typedef enum
  21. {
  22. fstFAT,
  23. fstNTFS,
  24. fstOFS,
  25. fstUnknown
  26. } enumFileSystemType;
  27. // ----------
  28. // CDirectory
  29. // ----------
  30. class CDirectory
  31. {
  32. // Construction/Deconstruction
  33. public:
  34. CDirectory();
  35. ~CDirectory();
  36. // Public Member Functions
  37. public:
  38. BOOL Initialize(); // Defaulted input
  39. BOOL Initialize( LPCWSTR wszDirectory ); // Unicode input
  40. BOOL Initialize( LPCSTR szDirectory ); // ANSI input
  41. enumFileSystemType GetFileSystemType() const;
  42. LPCWSTR GetFileSystemName() const;
  43. LPCWSTR GetDirectoryName() const;
  44. // Private Member Functions
  45. private:
  46. void DisplayErrors( BOOL bSuccess, LPCWSTR wszFunctionName );
  47. VOID MakeRoot(WCHAR *pwszPath);
  48. unsigned GetRootLength(const WCHAR *pwszPath);
  49. // Member Data
  50. private:
  51. WCHAR m_wszDirectory[ MAX_UNICODE_PATH + sizeof( L'\0' )];
  52. WCHAR m_wszFileSystemName[ MAX_UNICODE_PATH + sizeof( L'\0' )];
  53. enumFileSystemType m_FileSystemType;
  54. WCHAR m_wszErrorMessage[ 200 ];
  55. long m_lError;
  56. };
  57. // ----------------
  58. // Inline Functions
  59. // ----------------
  60. // CDirectory::CDirectory
  61. inline CDirectory::CDirectory()
  62. {
  63. wcscpy( m_wszDirectory, L"" );
  64. wcscpy( m_wszFileSystemName, L"" );
  65. wcscpy( m_wszErrorMessage, L"" );
  66. m_lError = 0;
  67. m_FileSystemType = fstUnknown;
  68. }
  69. // CDirectory::~CDirectory
  70. inline CDirectory::~CDirectory()
  71. {
  72. }
  73. // CDirectory::GetFileSystemType
  74. inline enumFileSystemType CDirectory::GetFileSystemType() const
  75. {
  76. return m_FileSystemType;
  77. }
  78. // CDirectory::GetFileSystemName
  79. inline LPCWSTR CDirectory::GetFileSystemName() const
  80. {
  81. return m_wszFileSystemName;
  82. }
  83. // CDirectory::GetDirectoryName
  84. inline LPCWSTR CDirectory::GetDirectoryName() const
  85. {
  86. return m_wszDirectory;
  87. }
  88. // CDirectory::DisplayErrors
  89. inline void CDirectory::DisplayErrors( BOOL bSuccess, LPCWSTR wszFunctionName )
  90. {
  91. if( !bSuccess )
  92. {
  93. wprintf( L"Error in %s (%08x)\n %s\n",
  94. wszFunctionName, m_lError, m_wszErrorMessage );
  95. }
  96. }
  97. // ------
  98. // Macros
  99. // ------
  100. // Early-exit macro.
  101. #undef EXIT
  102. #define EXIT( error ) \
  103. {\
  104. wcscpy( m_wszErrorMessage, ##error );\
  105. goto Exit;\
  106. }
  107. #endif // _C_DIR_HXX_