summaryrefslogtreecommitdiffstats
path: root/private/oleutest/cfmex/cdir.hxx
blob: 7feaf8851179d7e337116119a4c8edc572cf5837 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161


//+-----------------------------------------------------------------------
//
//  File:       CDir.hxx
//
//  Purpose:    Declare the CDirectory class.  Objects of this class
//              are used to represent a directory, and provide additional
//              information about it.
//
//+-----------------------------------------------------------------------


#ifndef _C_DIR_HXX_
#define _C_DIR_HXX_

//  --------
//  Includes
//  --------

#include "CFMEx.hxx"


//  --------
//  Typedefs
//  --------

// An enumeration of the possible file system types.

typedef enum
{
    fstFAT,
    fstNTFS,
    fstOFS,
    fstUnknown
} enumFileSystemType;


//  ----------
//  CDirectory
//  ----------

class CDirectory
{

//  Construction/Deconstruction

public:

    CDirectory();
    ~CDirectory();

// Public Member Functions

public:

    BOOL Initialize();                          // Defaulted input
    BOOL Initialize( LPCWSTR wszDirectory );    // Unicode input
    BOOL Initialize( LPCSTR  szDirectory );     // ANSI input

    enumFileSystemType GetFileSystemType() const;
    LPCWSTR GetFileSystemName() const;
    LPCWSTR GetDirectoryName() const;


// Private Member Functions

private:

    void DisplayErrors( BOOL bSuccess, LPCWSTR wszFunctionName );
    VOID MakeRoot(WCHAR *pwszPath);
    unsigned GetRootLength(const WCHAR *pwszPath);


// Member Data

private:

    WCHAR m_wszDirectory[ MAX_UNICODE_PATH + sizeof( L'\0' )];
    WCHAR m_wszFileSystemName[ MAX_UNICODE_PATH + sizeof( L'\0' )];
    enumFileSystemType m_FileSystemType;

    WCHAR m_wszErrorMessage[ 200 ];
    long m_lError;

};


//  ----------------
//  Inline Functions
//  ----------------


//  CDirectory::CDirectory

inline CDirectory::CDirectory()
{
    wcscpy( m_wszDirectory, L"" );
    wcscpy( m_wszFileSystemName, L"" );
    wcscpy( m_wszErrorMessage, L"" );
    m_lError = 0;
    m_FileSystemType = fstUnknown;

}

//  CDirectory::~CDirectory

inline CDirectory::~CDirectory()
{
}

// CDirectory::GetFileSystemType

inline enumFileSystemType CDirectory::GetFileSystemType() const
{
    return m_FileSystemType;
}

//  CDirectory::GetFileSystemName

inline LPCWSTR CDirectory::GetFileSystemName() const
{
    return m_wszFileSystemName;
}

//  CDirectory::GetDirectoryName

inline LPCWSTR CDirectory::GetDirectoryName() const
{
    return m_wszDirectory;
}


//  CDirectory::DisplayErrors

inline void CDirectory::DisplayErrors( BOOL bSuccess, LPCWSTR wszFunctionName )
{
    if( !bSuccess )
    {
        wprintf( L"Error in %s (%08x)\n   %s\n",
                 wszFunctionName, m_lError, m_wszErrorMessage );
    }
}


//  ------
//  Macros
//  ------

// Early-exit macro.

#undef EXIT
#define EXIT( error )               \
                                    {\
                                       wcscpy( m_wszErrorMessage, ##error );\
                                       goto Exit;\
                                    }



#endif // _C_DIR_HXX_