| MikroCAD SDK Library

- Home
- All Types
- Files

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FileFunc.h
Go to the documentation of this file.
1 /**
2 * @file FileFunc.h
3 * @brief File functions
4 *
5 * @author LMI Technologies
6 */
7
8 #ifndef _FileFunc_h
9 #define _FileFunc_h
10
11 #include "windows.h"
12 #include <string>
13
14 using namespace std;
15
16 /**
17 Standard directories
18 */
19 struct TSpecialDirectories
20 {
21 wstring m_stWindowsDirectory;
22 wstring m_stSystemDirectory;
23 wstring m_stCommonAppDataDirectory;
24 wstring m_stAppDataDirectory;
25 wstring m_stLocalAppDataDirectory;
26
27 TSpecialDirectories();
28 };
29
30 /**
31 Class for path operations (static functions)
32 */
33 class CPath
34 {
35 public:
36
37 static wstring ExtractFileDir(wstring stPath);
38
39 static wstring ExtractFilePath(wstring stPath);
40
41 static wstring ExtractFileName(wstring stPath);
42
43 static wstring ExtractFileNameWithoutExt(wstring stPath);
44
45 static wstring ExtractFileExt(wstring stPath);
46
47 static wstring ChangeFileExt(wstring stPath, wstring stExt);
48
49 static wstring GetFullProgramPath();
50
51 static wstring GetProgramPath();
52
53 static wstring GetProgramFileName();
54
55 static wstring GetProgramFileNameWithoutExt();
56
57 static TSpecialDirectories* GetSpecialDirectories()
58 {
59 return &m_SpecialDirectories;
60 };
61
62 private:
63
64 static bool SplitPath(wstring stPath, wstring& stDrive, wstring& stDir, wstring& stName, wstring& stExt);
65
66 private:
67
68 static TSpecialDirectories m_SpecialDirectories;
69 };
70
71 /**
72 Class for directory operations (static functions)
73 */
74 class CDirectory
75 {
76 public:
77
78 static bool Create(wstring stDirectoryName);
79
80 static bool Exists(wstring stDirectoryName);
81 };
82
83 /**
84 File open modes
85 */
86 enum eFileOpenMode
87 {
88 FileOpenMode_Create = 1,
89 FileOpenMode_Read = 2,
90 FileOpenMode_Write = 3,
91 FileOpenMode_ReadWrite = 4,
92 FileOpenMode_Append = 5,
93 };
94
95 /**
96 File search modes
97 */
98 enum eFileSearchMode
99 {
100 FileSearchMode_Begin,
101 FileSearchMode_Current,
102 FileSearchMode_End,
103 };
104
105 /**
106 Class for file operations
107 */
108 class CDataFile
109 {
110 public:
111
112 CDataFile(wstring stFileName, eFileOpenMode Mode);
113
114 virtual ~CDataFile();
115
116 long Read(void* pData, DWORD dwDataLength);
117
118 long Write(void* pData, DWORD dwDataLength);
119
120 long Seek(eFileSearchMode SearchMode, long lOffset);
121
122 long Tell();
123
124 long Size();
125
126 static long Size(wstring stFileName);
127
128 static bool Exists(wstring stFileName);
129
130 static long ReadAllBytes(wstring stFileName, BYTE* pbyBuffer, long lBufferSize);
131
132 static long WriteAllBytes(wstring stFileName, BYTE* pbyBuffer, long lBufferSize);
133
134 static long ReadAllWChars(wstring stFileName, wchar_t* pszBuffer, long lBufferSize);
135
136 static long WriteAllWChars(wstring stFileName, wchar_t* pszBuffer, long lBufferSize);
137
138 static bool IsReadOnly(wstring stFileName);
139
140 static void SetReadOnly(wstring stFileName);
141
142 static void SetReadWrite(wstring stFileName);
143
144 static void DeleteFile(wstring stFileName);
145
146 private:
147
148 FILE *m_pFile;
149 };
150
151 /**
152 Get file version as string
153 */
154 wstring GetFileVersion(wstring stFileName);
155
156 /**
157 Get file version as DWORD
158 */
159 DWORD dwGetFileVersion(wstring stFileName);
160
161 #endif // _FileFunc_h
TSpecialDirectories
Standard directories.
Definition: FileFunc.h:19
GetFileVersion
wstring GetFileVersion(wstring stFileName)
Get file version as string.
eFileOpenMode
eFileOpenMode
File open modes.
Definition: FileFunc.h:86
std
CDataFile
Class for file operations.
Definition: FileFunc.h:108
CPath
Class for path operations (static functions)
Definition: FileFunc.h:33
eFileSearchMode
eFileSearchMode
File search modes.
Definition: FileFunc.h:98
dwGetFileVersion
DWORD dwGetFileVersion(wstring stFileName)
Get file version as DWORD.
CDirectory
Class for directory operations (static functions)
Definition: FileFunc.h:74