d2c_sysfile |
Top Previous Next |
Pretranslated C++ code > Delphi RTL/VCL > C++ code for other compilers > d2c_sysfile d2c_sysfile contains Delphi2Cpp II helper code for basic file reading and writing routines.
struct TFileRec { THandle Handle; int Mode; WORD Flags; unsigned int RecSize; unsigned char _private [ 28 ]; unsigned char UserData [ 32 ]; Char Name [ 260 ]; };
template <typename T> struct TTypedFile { THandle Handle; int Mode; WORD Flags; unsigned int RecSize; unsigned char _private [ 28 ]; unsigned char UserData [ 32 ]; Char Name [ 260 ]; };
typedef char TextBufA [ 260 ];
struct TTextRec { THandle Handle; int Mode; WORD Flags; unsigned int BufSize; unsigned int BufPos; unsigned int BufEnd; char* BufPtr; void* OpenFunc; void* InOutFunc; void* FlushFunc; void* CloseFunc; unsigned char UserData [ 32 ]; Char Name [ 260 ]; WORD CodePage; char LineEnd[3]; TextBufA Buffer; };
typedef TTypedFile<unsigned char> file; typedef TTextRec Text; typedef TTextRec *ptext;
// System.h enum TTextLineBreakStyle {tlbsLF, tlbsCRLF, tlbsCR };
extern bool FileNameCaseSensitive; extern bool CtrlZMarksEOF; extern TTextLineBreakStyle DefaultTextLineBreakStyle;
const Char DirectorySeparator = _T('\\'); const Char DriveSeparator = _T(':'); const Char PathSeparator = _T(';'); const int MaxPathLen = 260;
extern THandle UnusedHandle; extern THandle StdInputHandle; extern THandle StdOutputHandle; extern THandle StdErrorHandle;
const bool LFNSupport = true; const char ExtensionSeparator = '.'; extern TSet < UChar, 0, 255 > AllowDirectorySeparators; extern TSet < UChar, 0, 255 > AllowDriveSeparators;
extern bool FileNameCaseSensitive; extern bool CtrlZMarksEOF;
const int fsFromBeginning = 0; const int fsFromCurrent = 1; const int fsFromEnd = 2;
const THandle feInvalidHandle = ((THandle) - 1 ); //return value on FileOpen error
/* file input modes */ const int fmClosed = 0xD7B0; const int fmInput = 0xD7B1; const int fmOutput = 0xD7B2; const int fmInOut = 0xD7B3; //const int fmAppend = 0xD7B4; extern TTextRec ErrOutput, Output, Input, Stdout, Stderr; //extern unsigned char FileMode; // System.h WORD IOResult( );
const int fmAppend = 0xD7B4; // unknown in C++Builder 6?
typedef void ( * FileFunc )( TTextRec& );
/**************************************************************************** Untyped File Management ****************************************************************************/
void AssignFile( TFileRec& f, const String& Name ); void AssignFile( TFileRec& f, Char c ); void Assign( TFileRec& f, const String& Name );
void Rewrite( TFileRec& f, int l = 128 ); void Reset( TFileRec& f, int l = 128 ); void CloseFile( TFileRec& f ); void Close( TFileRec& f );
void BlockWrite( TTypedFile<unsigned char>& f, void*& buf, int64_t Count, int& Result ); void BlockWrite( TTypedFile<unsigned char>& f, void*& buf, int Count, int& Result ); void BlockWrite( TTypedFile<unsigned char>& f, void*& buf, WORD Count, WORD& Result ); void BlockWrite( TTypedFile<unsigned char>& f, void*& buf, unsigned int Count, unsigned int& Result ); void BlockWrite( TTypedFile<unsigned char>& f, void*& buf, WORD Count, int& Result ); void BlockWrite( TTypedFile<unsigned char>& f, void*& buf, int Count ); void BlockRead( TTypedFile<unsigned char>& f, void*& buf, int Count, int& Result ); void BlockRead( TTypedFile<unsigned char>& f, void*& buf, int64_t Count ); int64_t FileSize( TFileRec& f ); // FileSize can't be used on a text TTypedFile<unsigned char>. int64_t FilePos( TFileRec& f, int l = 128 ); void Seek( TTypedFile<unsigned char>& f, int64_t Pos ); void Rename( TTypedFile<unsigned char>& f, const char* P ); void Rename( TTypedFile<unsigned char>& f, const wchar_t* P ); void Rename( TTypedFile<unsigned char>& f, const AnsiString& s ); void Rename( TTypedFile<unsigned char>& f, const WideString& s ); void Rename( TTypedFile<unsigned char>& f, char c ); void Rename( TTypedFile<unsigned char>& f, wchar_t c ); bool Eof( TFileRec& f, int l = 128 ); void Truncate( TFileRec& f, int RecSize );
template <typename T> void AssignFile( TTypedFile<T>& f, const String& Name ) ... template <typename T> void AssignFile( TTypedFile<T>& f, const Char* P ) ... template <typename T> void AssignFile( TTypedFile<T>& f, Char c ) ... template <typename T> int64_t FileSize( TTypedFile<T>& f ) ... template <typename T> bool Eof( TTypedFile<T>& f ) ... template <typename T> void CloseFile( TTypedFile<T>& f ) ... template <typename T> void Close( TTypedFile<T>& f ) ... template <typename T> void Reset( TTypedFile<T>& f, int l = -1 ) ... template <typename T> void Rewrite( TTypedFile<T>& f, int l = -1 ) ... template <typename T> void Write( TTypedFile<T>& f, void* buf ) ... template <typename T> void Read( TTypedFile<T>& f, void* buf ) ... template <typename T> void Truncate( TTypedFile<T>& f ) ...
/**************************************************************************** Text File Management ****************************************************************************/
void Assign( TTextRec& f, const String& Name ); void Assign( TTextRec& t, Char c ); void AssignFile( TTextRec& f, const String& Name ); void AssignFile( TTextRec& t, Char c ); void CloseFile( TTextRec& t ); void Close( TTextRec& t ); void Rewrite( TTextRec& t ); void Reset( TTextRec& t ); void Append( TTextRec& t ); // System.h void Flush( TTextRec& t ); void Erase( TTextRec& t ); void Rename( TTextRec& t, const char* P ); void Rename( TTextRec& t, const wchar_t* P ); void Rename( TTextRec& t, const AnsiString& s ); void Rename( TTextRec& t, const WideString& s ); void Rename( TTextRec& t, char c ); void Rename( TTextRec& t, wchar_t c ); bool Eof( TTextRec& t ); bool Eof( ); bool EoLn( TTextRec& t ); bool EoLn( ); bool SeekEof( TTextRec& t ); bool SeekEof( ); bool SeekEoLn( TTextRec& t ); bool SeekEoLn( ); void SetTextBuf( TTextRec& t, void* buf, int size ); void SetTextLineEnding(TTextRec& t, String& Ending);
void Write( TTextRec& t, const SmallString<255> s, int Len = 0 ); void Write( TTextRec& t, const char* P, int Len = 0 ); void Write( TTextRec& t, const AnsiString& s, int Len = 0 ); void Write( TTextRec& t, const wchar_t* P, int Len = 0 ); void Write( TTextRec& t, const WideString& s, int Len = 0 ); void Write( TTextRec& t, long l, int Len = 0 ); void Write( TTextRec& t, int l, int Len = 0 ); void Write( TTextRec& t, unsigned int l, int Len = 0 ); void Write( TTextRec& t, unsigned short l, int Len = 0 ); void Write( TTextRec& t, uint64_t q, int Len = 0 ); void Write( TTextRec& t, int64_t i, int Len = 0 ); void Write( TTextRec& t, long double r, int rt = -1, int fixkomma = -1 ); void Write( TTextRec& t, double r, int rt = -1, int fixkomma = -1 ); void Write( TTextRec& t, Currency c, int fixkomma = -1, int Len = 0 ); void Write( TTextRec& t, bool b, int Len = 0 ); void Write( TTextRec& t, char c, int Len = 0 ); void Write( TTextRec& t, unsigned char c, int Len = 0 ); void Write( TTextRec& t, wchar_t c, int Len = 0 ); void WriteLn( TTextRec& t ); void WriteLn( TTextRec& t, const SmallString<255> s, int Len = 0 ); void WriteLn( TTextRec& t, const char* P, int Len = 0 ); void WriteLn( TTextRec& t, const AnsiString& s, int Len = 0 ); void WriteLn( TTextRec& t, const wchar_t* P, int Len = 0 ); void WriteLn( TTextRec& t, const WideString& s, int Len = 0 ); void WriteLn( TTextRec& t, long l, int Len = 0 ); void WriteLn( TTextRec& t, int l, int Len = 0 ); void WriteLn( TTextRec& t, unsigned int l, int Len = 0 ); void WriteLn( TTextRec& t, unsigned short l, int Len = 0 ); void WriteLn( TTextRec& t, uint64_t q, int Len = 0 ); void WriteLn( TTextRec& t, int64_t i, int Len = 0 ); void WriteLn( TTextRec& t, long double r, int rt = -1, int fixkomma = -1 ); void WriteLn( TTextRec& t, double r, int rt = -1, int fixkomma = -1 ); void WriteLn( TTextRec& t, Currency c, int fixkomma, int Len = -1 ); void WriteLn( TTextRec& t, bool b, int Len = 0 ); void WriteLn( TTextRec& t, char c, int Len = 0 ); void WriteLn( TTextRec& t, unsigned char c, int Len = 0 ); void WriteLn( TTextRec& t, wchar_t c, int Len = 0 ); void Write( const SmallString<255> s, int Len = 0 ); void Write( const char* P, int Len = 0 ); void Write( const AnsiString& s, int Len = 0 ); void Write( long l, int Len = 0 ); void Write( int l, int Len = 0 ); void Write( unsigned int l, int Len = 0 ); void Write( uint64_t q, int Len = 0 ); void Write( int64_t i, int Len = 0 ); void Write( long double r, int rt = -1, int fixkomma = -1 ); void Write( double r, int rt = -1, int fixkomma = -1 ); void Write( Currency c, int fixkomma = -1, int Len = 0 ); void Write( bool b, int Len = 0 ); void Write( char c, int Len = 0 ); void WriteLn( ); void WriteLn( const SmallString<255> s, int Len = 0 ); void WriteLn( const char* P, int Len = 0 ); void WriteLn( const AnsiString& s, int Len = 0 ); void WriteLn( long l, int Len = 0 ); void WriteLn( int l, int Len = 0 ); void WriteLn( unsigned int l, int Len = 0 ); void WriteLn( uint64_t q, int Len = 0 ); void WriteLn( int64_t i, int Len = 0 ); void WriteLn( long double r, int rt = -1, int fixkomma = -1 ); void WriteLn( double r, int rt = -1, int fixkomma = -1 ); void WriteLn( Currency c, int fixkomma = -1, int Len = 0 ); void WriteLn( bool b, int Len = 0 ); void WriteLn( char c, int Len = 0 ); void Write( wchar_t c, int Len = 0); void WriteLn( wchar_t c, int Len = 0 ); void Write( const wchar_t* P, int Len = 0 ); void Write( const WideString& s, int Len = 0 ); void WriteLn( const wchar_t* P, int Len = 0 ); void WriteLn( const WideString& s, int Len = 0 );
void Read( TTextRec& t, SmallString<255>& s ); void Read( TTextRec& t, char* s, int maxlen = 0x7FFFFFFF ); void Read( TTextRec& t, AnsiString& s ); void Read( TTextRec& t, char& c ); void Read( TTextRec& t, WideString& s ); void Read( TTextRec& t, wchar_t& c ); void Read( TTextRec& t, unsigned int& u ); void Read( TTextRec& t, unsigned short& u ); void Read( TTextRec& t, long double& v ); void Read( TTextRec& f, Currency& v ); void Read( TTextRec& t, double& v ); void Read( TTextRec& t, int64_t& i ); void Read( TTextRec& t, uint64_t& q ); void ReadLn( TTextRec& t); void ReadLn( TTextRec& t, SmallString<255>& s ); void ReadLn( TTextRec& t, char* s, int maxlen = 0x7FFFFFFF ); void ReadLn( TTextRec& t, AnsiString& s ); void ReadLn( TTextRec& t, char& c ); void ReadLn( TTextRec& t, WideString& s ); void ReadLn( TTextRec& t, wchar_t& c ); void ReadLn( TTextRec& t, int& l ); void ReadLn( TTextRec& t, unsigned int& u ); void ReadLn( TTextRec& t, unsigned short& u ); void ReadLn( TTextRec& t, long double& v ); void ReadLn( TTextRec& f, Currency& v ); void ReadLn( TTextRec& t, double& v ); void ReadLn( TTextRec& t, int64_t& i ); void ReadLn( TTextRec& t, uint64_t& q ); void Read( SmallString<255>& s ); void Read( char* s, int maxlen = 0x7FFFFFFF ); void Read( AnsiString& s ); void Read( char& c ); void Read( WideString& s ); void Read( wchar_t& c ); void Read( int& l ); void Read( unsigned int& u ); void Read( long double& v ); void Read( double& v ); void Read( Currency& v ); void Read( int64_t& i ); void Read( uint64_t& q ); void ReadLn( ); void ReadLn( SmallString<255>& s ); void ReadLn( char* s, int maxlen = 0x7FFFFFFF ); void ReadLn( AnsiString& s ); void ReadLn( char& c ); void ReadLn( WideString& s ); void ReadLn( wchar_t& c ); void ReadLn( int& l ); void ReadLn( unsigned int& u ); void ReadLn( unsigned short& u ); void ReadLn( long double& v ); void ReadLn( double& v ); void ReadLn( Currency& v ); void ReadLn( int64_t& i ); void ReadLn( uint64_t& q );
template <unsigned char sz> void Write( TTextRec& t, SmallString<sz> s, int Len = 0 ) ... template <unsigned char sz> void WriteLn( TTextRec& t, SmallString<sz> s, int Len = 0 ) ... template <unsigned char sz> void Write( SmallString<sz> s, int Len = 0 ) ... template <unsigned char sz> void WriteLn( SmallString<sz> s, int Len = 0 ) ... template <unsigned char sz> void Read( TTextRec& t, SmallString<sz>& s ) ... template <unsigned char sz> void ReadLn( TTextRec& t, SmallString<sz>& s ) ... template <unsigned char sz> void Read( SmallString<sz>& s ) ... template <unsigned char sz> void ReadLn( SmallString<sz>& s ) ...
void SetLineBreakStyle(System::Text& T, TTextLineBreakStyle Style); WORD GetTextCodePage(const System::Text T); void SetTextCodePage(System::Text& T, WORD CodePage); void Flush(System::Text& T);
void InOutError(); void SetInOutRes(int NewValue);
|
This page belongs to the DelphiXE2Cpp11 Documentation |
DelphiXE2Cpp11 home Content |