9#if !defined(OWL_FILE_H)
13#if defined(BI_HAS_PRAGMA_ONCE)
89#define BINNTYPE (varLastMember+1)
105#define TFILE_ERROR static_cast<uint32>(-1)
108#define FileNull nullptr
110#define TFILE64_ERROR uint64(0xFFFFFFFF)
132 ReadWrite = WriteOnly|ReadOnly,
140 PermReadWrite = PermWrite|PermRead,
141 PermExclusive = 0x0040,
148 CreateAlways = 0x0200,
151 OpenExisting = 0x0400,
156 TruncateExist = 0x0800,
197 virtual bool Close();
200 virtual uint64 Position64()
const;
201 virtual uint64 Length64()
const;
203 virtual uint32 Position()
const;
204 virtual uint32 Length()
const;
215 uint32 GetOpenMode()
const;
220 virtual bool Flush();
240#if defined(OWL5_COMPAT)
249 virtual uint8 readUint8();
250 virtual uint16 readUint16();
251 virtual uint32 readUint32();
252 virtual uint64 readUint64();
253 virtual float readFloat();
254 virtual double readDouble();
257 virtual void writeUint8(
const uint8 );
258 virtual void writeUint16(
const uint16 );
259 virtual void writeUint32(
const uint32 );
260 virtual void writeUint64(
const uint64 );
261 virtual void writeFloat(
const float );
262 virtual void writeDouble(
const double );
263 virtual void writeString(
const tchar *);
331 virtual uint32 LastError();
334 virtual bool Close();
338 virtual uint64 Position64()
const;
339 virtual uint64 Length64()
const;
341 virtual uint32 Position()
const;
342 virtual uint32 Length()
const;
345 virtual bool Flush();
350 virtual bool GetStatus(
TFileStatus & status)
const;
372 enum { DefaultBufferSize = 2048};
382 virtual bool Close();
384 virtual uint64 Position64()
const;
385 virtual uint64 Length64()
const;
386 virtual uint32 Position()
const;
387 virtual uint32 Length()
const;
395 virtual bool Flush();
398 virtual void SetBuffer(
uint8*
buffer,
uint size,
bool shouldDelete =
true);
402 virtual void InitBuffer(
uint size = DefaultBufferSize);
403 virtual bool FlushBuffer();
445 virtual bool WriteString(
LPCTSTR str);
449 virtual uint8 readUint8();
450 virtual uint16 readUint16();
451 virtual uint32 readUint32();
452 virtual uint64 readUint64();
453 virtual float readFloat();
454 virtual double readDouble();
457 virtual void writeUint8(
const uint8 );
458 virtual void writeUint16(
const uint16 );
459 virtual void writeUint32(
const uint32 );
460 virtual void writeUint64(
const uint64 );
461 virtual void writeFloat(
const float );
462 virtual void writeDouble(
const double );
463 virtual void writeString(
const tchar *);
478 operator const tchar*()
const;
480 const tchar* Current()
const;
486 virtual bool NextLine();
525# define owlFCC(ch4) (((static_cast<DWORD>(ch4) & 0xFF) << 24) | \
526 ((static_cast<DWORD>(ch4) & 0xFF00) << 8) | \
527 ((static_cast<DWORD>(ch4) & 0xFF0000) >> 8) | \
528 ((static_cast<DWORD>(ch4) & 0xFF000000) >> 24))
531# define owlFCC(ch0, ch1, ch2, ch3) \
532 (static_cast<uint32>(static_cast<uint8>(ch0)) | (static_cast<uint32>(static_cast<uint8>(ch1)) << 8) | \
533 (static_cast<uint32>(static_cast<uint8>(ch2)) << 16) | (static_cast<uint32>(static_cast<uint8>(ch3)) << 24 ))
568 ffFindChunk = 0x0004,
584 bool CreateChunk(
TCkInfo&
info,
const TCreateFlags = cfCreateChunk);
616 ffFindChunk = 0x0002,
626 const TFindFlags = TFindFlags(ffFindChunk|ffReset));
656 virtual uint32 LastError();
658 virtual bool IsOpen();
662 virtual bool Close();
666 virtual uint64 Position64()
const;
667 virtual uint64 Length64()
const;
669 virtual uint32 Position()
const;
670 virtual uint32 Length()
const;
673 virtual bool Flush();
678 virtual bool GetStatus(
TFileStatus & status)
const;
933 i =
file.readUint16();
938 i =
static_cast<signed int>(
file.readUint32());
943 i =
static_cast<uint>(
file.readUint32());
948 b =
static_cast<bool>(
file.readUint32());
957 i =
file.readUint32();
965 i =
file.readUint64();
969 f =
file.readFloat();
973 d =
file.readDouble();
977 file.readString(str);
998 file.writeUint32(
static_cast<signed int>(
i));
1030 file.writeDouble(
d);
1034 file.writeString(s);
1038 size_t size = s.length();
1039 file.writeUint32(
static_cast<int>(size));
1040 file.Write(s.c_str(),
static_cast<int>(size));
1187inline TFileLineIterator::operator
const tchar*()
const{
1188 return Done ?
nullptr : LineBuffer;
1221: CkId(0),Size(0),Type(0),Offset(0),Flags(0)
1252: Size(0),Type(0),Offset(0),Flags(0)
#define PRECONDITION(condition)
The TBufferedFile class is derived from TFile encapsulates standard file characteristics and operatio...
TBufferedFile()
Creates a TBufferedFile object with a file handle of FileNull and allocated a buffer of DefaultBuffer...
virtual uint32 Length() const
Returns the file length plus the length of unwritten data in the buffer.
virtual bool Write(const void *buffer, uint32 numBytes)
Writes numBytes of buffer to the file.
uint32 EndPos
Offset in file to the last data byte in the buffer.
virtual bool FlushBuffer()
Flushes the buffer by writing any unwritten data to the file.
uint8 * CurByte
Pointer to current position in the buffer.
virtual uint64 Length64() const
Returns the file length plus the length of unwritten data in the buffer.
virtual void InitBuffer(uint size=DefaultBufferSize)
Allocates a buffer of size bytes.
uint FileBufSize
Size of FileBuffer in bytes.
uint8 * FileBuffer
Buffer used to store data in.
bool BufferEmpty
True if the buffer is empty; false otherwise.
virtual uint64 Position64() const
Returns the current position of the file pointer.
virtual bool Close()
Flushes the buffer and closes the file.
uint32 StartPos
Offset in file to byte 0 of the buffer.
virtual bool Flush()
Writes any data in the buffer to file and then resets the buffer.
virtual uint32 Position() const
Returns the current position of the file pointer.
uint32 CurPos
Offset in file to current position.
bool ShouldDelete
True if the buffer should be deleted.
virtual const tstring GetName()
virtual uint GetOpenMode()
virtual uint32 Length() const =0
virtual bool LockRange(uint32 position, uint32 count)=0
virtual bool Length(uint64 newLen)=0
virtual TFileHandle * Clone() const =0
virtual bool GetStatus(TFileStatus &status) const =0
virtual bool UnlockRange(uint32 position, uint32 count)=0
virtual bool Write(const void *buffer, uint32 numBytes)=0
virtual uint32 LastError()=0
virtual uint64 Position64() const =0
virtual uint32 Seek(long offset, TFile::TSeekDir origin=TFile::beg)=0
virtual uint GetOpenMode()=0
virtual uint32 Read(void *buffer, uint32 numBytes)=0
virtual uint64 Seek(int64 offset, TFile::TSeekDir origin=TFile::beg)=0
virtual bool LockRange(uint64 position, uint64 count)=0
virtual bool UnlockRange(uint64 position, uint64 count)=0
virtual uint32 Position() const =0
virtual const tstring GetName()=0
virtual uint64 Length64() const =0
virtual bool Length(uint32 newLen)=0
The TFile class encapsulates standard file characteristics and operations.
virtual bool Open(const tstring &fileName, const uint32 mode=ReadOnly|PermRead|OpenExisting)
Opens file name with the given mode.
bool IsOpen() const
Returns true if the file is open, false otherwise.
virtual uint32 Length() const
Returns the file length.
uint BufSize
Size of Buffer used with structure read/write.
virtual uint64 Seek(int64 offset, TSeekDir origin=beg)
Repositions the file pointer to offset bytes from the specified origin.
bool ShouldClose
Should C++ object close file on dtor.
TOpenMode
Open mode -> remapped into OS specific value internally.
uint8 * Buffer
Buffer used with structure read/write.
virtual TCHAR * readString(tchar *)
virtual bool Flush()
Performs any pending I/O functions. Returns true if successful; false otherwise.
virtual void writeString(const tchar *)
uint64 SeekToEnd64()
Repositions the file pointer to the end of the file.
virtual bool LockRange(uint32 position, uint32 count)
Locks count bytes, beginning at position of the file.
virtual uint32 Read(void *buffer, uint32 numBytes)
Reads numBytes from the file into buffer. The number of bytes read is returned.
virtual uint64 Length64() const
Returns the file length.
uint64 SeekToBegin64()
Repositions the file pointer to the beginning of the file.
TFileHandle * Handle
Low-level C file handle.
virtual bool Write(const void *buffer, uint32 numBytes)
Writes numbytes of buffer to the file.
virtual bool UnlockRange(uint32 position, uint32 count)
Unlocks the range at the given Position.
uint32 GetOpenMode() const
Returns OpenMode.
TAttribute
file attributes -> internally remapped into OS values
uint32 SeekToEnd()
Repositions the file pointer to the end of the file.
uint32 SeekToBegin()
Repositions the file pointer to the beginning of the file.
const tstring GetName() const
Returns Name.
TFile()
Creates a TFile object with a file handle of FileNull.
TBinType
Binary data type enumerations.
virtual TFileHandle * GetHandle() const
Returns Handle.
uint32 LastError()
Returns the last error.
@ end
Seek from the end of the file.
@ beg
Seek from the beginning of the file.
virtual uint32 Position() const
Returns the current position of the file pointer.
virtual bool Close()
Closes the file. Returns true if successful, false otherwise.
bool GetStatus(TFileStatus &status) const
Fills status with the current file status.
virtual uint64 Position64() const
32 Bit Only: Returns the current position of the file pointer.
The TFileLineIterator class is used to iterate through a TTextFile file.
virtual bool NextLine()
Loads the next line in the file. Returns true if successful; false otherwise.
TFileLineIterator()
Protected default constructor. Intializes everything to 0.
TCHAR * LineBuffer
Buffer lines of text are loaded into.
const tchar * operator*() const
Returns a pointer to the start of the buffer if the file has not been completely iterated through; ot...
uint Line() const
Returns the current line number.
uint BuffSize
Size of the buffer allocated for loading a line of text.
uint LineNumber
Current line number in buffer. Line numbering starts at 1.
const tchar * Current() const
Returns a pointer to the start of the buffer if the file has not been completely iterated through; ot...
TTextFile * File
Pointer to the file being iterated through.
const tchar * operator++()
Loads the next line in the file and then returns a pointer to the start of the buffer if the file has...
The TFileName class constructs filenames.
The TQtFile class is used for reading and writing QuickTime files.
TQtFile()
Default constructor.
The TRiffFile class is used for reading and writing RIFF files.
TRiffFile()
Default constructor.
virtual bool Open(const tstring &fileName, const uint32 mode=ReadOnly|PermRead|OpenExisting)
TStreamFile(TStreamFile &file)
virtual const tstring GetName()
virtual uint GetOpenMode()
The TTextFile class is derived from TBufferedFile and encapsulates standard file characteristics and ...
bool WriteString(const tstring &str)
virtual void writeString(const tchar *)
virtual TCHAR * readString(tchar *)
TTextFile()
Creates a TTextFile object with a file handle of FileNull and allocated a buffer of DefaultBufferSize...
virtual TCHAR * GetString(TCHAR *buffer, uint32 size)
Reads up to size characters and places them in buffer.
The TTime class encapsulates time functions and characteristics.
TXOwl is root class of the ObjectWindows exception hierarchy.
TByteOrderType
The byte order type.
TVarType
These identify host program variable types and let the binary I/O package read and write routines kno...
#define FileNull
Represents a NULL file handle.
TByteOrderType EndianType()
@ boLittle_Endian
LSB at lowest address: Intel //.
@ boBig_Endian
MSB at lowest address: Motorola //.
Object Windows Library (OWLNext Core)
owl::opstream & operator<<(owl::opstream &os, const TColor &c)
Insert the color value into a persistent output stream.
owl::ipstream & operator>>(owl::ipstream &is, TColor &c)
Extract the color value from a persistent input stream.
ObjectWindows exception class & function definitions.
The TBinField struct describes a group of like-typed fields in a structure to be read or written usin...
TVarType Type
Declared type of struct field.
RIFF chunk information data structure.
uint32 Flags
flags used by MMIO functions
uint32 Offset
offset of data portion of chunk
uint32 Type
form type or list type
tchar fullName[_MAX_PATH]
QuickTime atom information data structure.
uint32 Type
chunk identifier