Mobile API Reference  MicroStrategy 2019
File.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : File.h
3 // AUTHOR : vovechkin
4 // CREATION : 2001-11-28
5 // Copyright (C) MicroStrategy Incorporated 2001
6 // All Rights Reserved
7 //==============================================================================================
8 #ifndef MFileSystem_File_h
9 #define MFileSystem_File_h
10 
11 #include <stdio.h>
12 #include <string.h>
13 
14 #include "FileSystem.h"
15 
16 namespace MDataType
17 {
18  // forward declarations
19  class DateTime;
20  class Binary;
21 }
22 
23 namespace MFileSystem
24 {
29  {
30  public:
31 
37  static void Move( const char* ipPathFrom, const char* ipPathTo );
38 
45  static bool Delete(const char* ipPath);
46 
57  static void Copy(const char* ipPathFrom, const char* ipPathTo, MDataType::Binary& irBinary);
58 
60  static void Copy(const char* ipPathFrom, const char* ipPathTo);
61 
63  static bool CopyAttributes(const char* ipPathFrom, const char* ipPathTo);
64 
68  static off_t GetSize( const char* ipPath );
69 
73  static void GetLastModified(const char* ipPath, MDataType::DateTime& orDateTime);
74 
75 
83 
93  enum OpenMode
94  {
95  OPEN_MODE_READ, // "r" --> read
96  OPEN_MODE_WRITE_FROM_SCRATCH, // "w" --> write/create/truncate
97  OPEN_MODE_WRITE_APPEND, // "a" --> write/create/append
98  OPEN_MODE_UPDATE_EXISTING, // "r+" --> read/write
99  OPEN_MODE_UPDATE_FROM_SCRATCH, // "w+" --> read/write/create/truncate
100  OPEN_MODE_UPDATE_APPEND, // "a+" --> read/write/create/append
101  OPEN_MODE_WRITE // write/create/NO truncate, This is added for OpenDescriptor
102  };
103 
108  {
109  SHARE_MODE_DEFAULT, // default sharing
110  SHARE_MODE_NONE, // no sharing at all
111  SHARE_MODE_READ, // other processes can read this file
112  SHARE_MODE_READ_AND_WRITE // other processes can read/write this file
113  };
114 
128  /* static int OpenDescriptor(
129  const char *ipPath,
130  OpenMode iOpenMode,
131  ShareMode iShareMode = SHARE_MODE_DEFAULT);
132 */
143  static FILE* OpenStream(
144  const char* ipPath,
145  OpenMode iOpenMode,
146  ShareMode iShareMode = SHARE_MODE_DEFAULT);
147 
148 
159  static void Copy(int iDescriptorFrom, int iDescriptorTo, MDataType::Binary& irBinary);
160  static void Copy(FILE* ipStreamFrom, FILE* ipStreamTo, MDataType::Binary& irBinary);
161 
163  static void Copy(int iDescriptorFrom, const char* ipPathTo);
164 
166  static void Copy(FILE* ipStreamFrom, const char* ipPathTo);
167 
173  static off_t GetSize(int inDescriptor);
174  static off_t GetSize(FILE* ipStream);
175 
188  static void Write( FILE* ipStream, const char* ipString, size_t iLength = 0 );
189 
193  static void Write( FILE* ipStream, const void* ipData, size_t iByteLength );
194 
201  static void Read(FILE* ipStream, MDataType::Binary& irBinary, size_t iMaxSize = 0);
202 
208  static void ReadLine(FILE* ipStream, MDataType::Binary& irBinary);
209 
213  static void Flush(int iDescriptor);
214  static void Flush(FILE* ipStream);
215 
219  static void Truncate(int iDescriptor, off_t iSize = 0);
220  static void Truncate(FILE* ipStream, off_t iSize = 0);
221 
225  static off_t GetPosition(int iDescriptor);
226  static off_t GetPosition(FILE* ipStream);
227 
231  static void MovePosition(int iDescriptor, off_t iOffset);
232 
238  static void MovePosition(FILE* ipStream, off_t iOffset);
239 
243  static void SetPosition(int iDescriptor, off_t iOffset);
244 
250  static void SetPosition(FILE* ipStream, off_t iOffset);
251 
259  static void CopyBlock(FILE* ipStream, MDataType::Binary& irBinary, off_t iTo, off_t iSize = 0);
260 
282  {
283  public:
284  WriteSmartLock( int iDescriptor );
285  WriteSmartLock(FILE* ipStream);
286  ~WriteSmartLock() throw();
287 
288  void Lock();
289  void Unlock() throw();
290 
291  private:
292  const int mDescriptor;
293  bool mIsLocked;
294  };
295 
306  {
307  public:
308  ReadSmartLock( int iDescriptor );
309  ReadSmartLock(FILE* ipStream);
310  ~ReadSmartLock() throw();
311 
312  void Lock();
313  void Unlock() throw();
314 
315  private:
316  const int mDescriptor;
317  bool mIsLocked;
318  };
319 
320  protected:
321  friend class WriteSmartLock;
322  friend class ReadSmartLock;
323 
324  friend class ReadableFileImpl;
325  friend class WriteableFileImpl;
326 
327  static void WriteLock(int iDescriptor, bool bIsWait = true);
328  static void ReadLock(int iDescriptor, bool bIsWait = true);
329  static void Unlock( int iDescriptor ) throw();
330  };
331 }
332 
333 #endif // MFileSystem_File_h
ShareMode
Definition: File.h:107
MDataType::Binary represents binary data.
Definition: Binary.h:33
Definition: ReadableFileImpl.h:22
Definition: BigDecimal.h:18
OpenMode
Definition: File.h:93
Definition: File.h:305
Definition: DateTime.h:74
Definition: File.h:281
Definition: WriteableFileImpl.h:22
Definition: StrongObjects.h:21
#define DLL_FILE_SYSTEM_EXIM
Definition: FileSystem.h:11
Definition: File.h:28