ADTF
file.h
Go to the documentation of this file.
1 
7 #ifndef _FILE_CLASS_HEADER_
8 #define _FILE_CLASS_HEADER_
9 
10 namespace A_UTILS_NS
11 {
12 
14 #ifdef WIN32
15  typedef tHandle tFileHandle;
16 #else
17  typedef int tFileHandle;
18 #endif
19 
25 class DOEXPORT cFile
26 {
28 
29  public:
31  typedef enum
32  {
36  OM_Read = 0x0001,
37 
40  OM_Write = 0x0002,
41 
43  OM_Append = 0x0004,
44 
47  OM_ReadWrite = 0x0008,
48 
52  OM_SharedRead = 0x0100,
53 
57  OM_SharedWrite = 0x0200,
58 
60  OM_SequentialAccess = 0x0400,
61 
64  OM_TemporaryFile = 0x0800,
65 
67  OM_ShortLived = 0x1000,
68 
71  OM_TextMode = 0x2000,
72 
74  OM_WriteThrough = 0x4000,
75 
77  OM_DisableFileSystemCache = 0x8000
78 
79  } tOpenMode;
80 
82  typedef enum
83  {
85  FP_Begin = 0,
86 
88  FP_Current = 1,
89 
91  FP_End = 2
92  } tFilePosRef;
93 
94  protected:
105 
106  public:
108  cFile();
109 
111  virtual ~cFile();
112 
133  tResult Open(const cFilename& strFilename, tUInt32 ui32Mode);
134 
144 
155 
165 
177  tBool SetReadCache(tInt nCacheSize);
178 
194  tInt Read(tVoid* pvBuffer, tInt nBufferSize);
195 
211  tResult ReadAll(tVoid* pvBuffer, tInt nBufferSize);
212 
224  tInt Skip(tInt nNumberOfBytes);
225 
244  tInt Write(const tVoid* pvBuffer, tInt nBufferSize);
245 
262  tResult WriteAll(const tVoid* pvBuffer, tInt nBufferSize);
263 
274  tInt Write(const cString& strString);
275 
285  tInt ReadLine(cString& strString);
286 
298  tInt WriteLine(const cString& strString);
299 
308 
317 
331 
357 
371 
377 
386  tBool IsValid() const;
387 
397 
398  protected:
403 
412 
419 
428  tVoid* InternalMalloc(tInt nSize, tBool bUseSegmentSize=tFalse);
429 
437  tVoid InternalFree(tVoid* pMemory, tBool bUseSegmentSize=tFalse);
438 };
439 
440 } // namespace A_UTILS_NS
441 
442 #endif // _FILE_CLASS_HEADER_
uint8_t tUInt8
type definition for unsigned integer values (8bit) (platform and compiler independent type).
tInt64 tFileSize
type definition for a file or stream size value (platform and compiler independent type).
tInt64 tFilePos
type definition for a file or stream position value (platform and compiler independent type).
void tVoid
The tVoid is always the definition for the void (non-type).
tVoid * tHandle
type definition for a handle value (platform and compiler dependent type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
File class.
Definition: file.h:26
tFilePos SetFilePos(tFilePos nOffset, tFilePosRef MoveMode)
This function moves the file pointer.
tBool m_bSystemCacheDisabled
System cache disabled.
Definition: file.h:102
tInt m_nFileCacheSize
File cache size.
Definition: file.h:99
tFilePosRef
File position reference.
Definition: file.h:83
tResult ReadAll(tVoid *pvBuffer, tInt nBufferSize)
This function reads data into a buffer from the file associated with the cFile object.
tResult Detach()
This function detaches existing references to file objects.
static tResult GetTimeCreation(const cFilename filename, A_UTILS_NS::cDateTime &dt)
This function returns the creation time of the file.
tBool IsValid() const
This function checks if the file object has an valid file handle.
tBool IsEof()
Checks whether or not the end of the file has been reached.
tVoid Initialize()
Initialization.
tInt ReadLine(cString &strString)
This function reads a line of text data into a cString object.
tInt Write(const cString &strString)
This function writes string data from a buffer to the file associated with the cFile object.
tVoid InternalFree(tVoid *pMemory, tBool bUseSegmentSize=tFalse)
Internal free method.
tInt m_nFileCacheOffset
File cache offset.
Definition: file.h:98
tUInt8 * m_pReadCache
File read cache.
Definition: file.h:96
tFilePos m_nSectorBytesToSkip
Sector bytes that will be skipped.
Definition: file.h:104
tResult Open(const cFilename &strFilename, tUInt32 ui32Mode)
This function opens an existing or creates a new file.
tInt m_nFileCacheUsage
File cache usage.
Definition: file.h:97
static tResult GetTimeAccess(const cFilename filename, A_UTILS_NS::cDateTime &dt)
This function returns the last access time of the file.
tFileHandle m_hFile
File handle.
Definition: file.h:95
tResult Truncate(tFilePos nSize)
This method truncates the file at the given size.
tInt WriteLine(const cString &strString)
This function writes string data from a buffer to the file associated with the cFile object.
tBool m_bReadCacheEnabled
Read cache enabled.
Definition: file.h:100
tFileSize GetSize() const
This function retrieves the file size.
tInt Read(tVoid *pvBuffer, tInt nBufferSize)
This function reads data into a buffer from the file associated with the cFile object.
tInt Skip(tInt nNumberOfBytes)
This function reads data from a file but does not store it .
static tResult GetTimeChange(const cFilename filename, A_UTILS_NS::cDateTime &dt)
This function returns the last change (write) time of the file.
tBool m_bReference
File is reference.
Definition: file.h:101
tResult WriteAll(const tVoid *pvBuffer, tInt nBufferSize)
This function writes data from a buffer to the file associated with the cFile object.
tResult Attach(cFile &oFile)
This function attaches an existing instance of a file class to another.
tBool SetReadCache(tInt nCacheSize)
This function sets the file read cache size.
tInt Write(const tVoid *pvBuffer, tInt nBufferSize)
This function writes data from a buffer to the file associated with the cFile object.
tVoid * InternalMalloc(tInt nSize, tBool bUseSegmentSize=tFalse)
Internal allocation method.
cFile()
Constructor.
tResult AllocReadCache(tInt nCacheSize)
Allocate read cache.
tFilePos GetFilePos() const
This function retrieves the file pointer offset.
virtual ~cFile()
Destructor. If handling an open file, the file is closed.
tInt m_nSectorSize
Sector size.
Definition: file.h:103
tResult FreeReadCache()
Free read cache.
tResult Close()
Close file.
File name class.
Definition: filename.h:59
#define tFalse
Value for tBool.
Definition: constants.h:60
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11
int tFileHandle
The type tFileHandle is used internally only.
Definition: file.h:17