Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
xb::xbFile Class Reference

Class for handling low level file I/O. More...

#include <xbfile.h>

Inheritance diagram for xb::xbFile:
xb::xbSsv xb::xbDbf

Public Member Functions

 xbFile (xbXBase *x)
 Class Constructor. More...
 
 ~xbFile ()
 Class Destructor. More...
 
const xbStringGetDirectory () const
 Get the directory name. More...
 
const xbStringGetFileName () const
 Get the file name. More...
 
const xbStringGetFqFileName () const
 Get the fully qualified file name. More...
 
xbInt16 CreateUniqueFileName (const xbString &sDirIn, const xbString &sExtIn, xbString &sFqnOut, xbInt16 iOption=0)
 Create a unique file name. More...
 
xbInt16 DetermineXbaseTableVersion (unsigned char cFileTypeByte) const
 Determine xbase dbf version. More...
 
xbInt16 DetermineXbaseMemoVersion (unsigned char cFileTypeByte) const
 Determine which version the memo (dbt) file is. More...
 
xbDouble eGetDouble (const char *p) const
 Get a portable double value. More...
 
xbInt32 eGetInt32 (const char *p) const
 Get a portable long value. More...
 
xbUInt32 eGetUInt32 (const char *p) const
 Get a portable unsigned long value. More...
 
xbInt16 eGetInt16 (const char *p) const
 Get a portable short value. More...
 
xbUInt16 eGetUInt16 (const char *p) const
 Get a portable unsigned short value. More...
 
void ePutDouble (char *p, xbDouble d)
 Write a portable double value to memory location. More...
 
void ePutInt32 (char *p, xbInt32 l)
 Write a portable long value to memory location. More...
 
void ePutUInt32 (char *p, xbUInt32 ul)
 Write a portable unsigned long value to memory location. More...
 
void ePutInt16 (char *p, xbInt16 s)
 Write a portable short value to memory location. More...
 
void ePutUInt16 (char *p, xbUInt16 s)
 Write a portable unsigned short value to memory location. More...
 
xbBool FileExists () const
 Determines if a file exists. More...
 
xbBool FileExists (xbInt16 iOption) const
 Determines if a file exists. More...
 
xbBool FileExists (const xbString &sFileName) const
 Determines if a file exists. More...
 
xbBool FileExists (const xbString &sFileName, xbInt16 iOption) const
 Determines if a file exists. More...
 
xbBool FileIsOpen () const
 Determines if file is open. More...
 
xbUInt32 GetBlockSize () const
 Get the block size. More...
 
xbInt16 GetFileDirPart (xbString &sFileDirPartOut) const
 Get the directory part of the file name. More...
 
xbInt16 GetFileDirPart (const xbString &sCompleteFileNameIn, xbString &sFileDirPartOut) const
 Get the directory part of the file name. More...
 
xbInt16 GetFileExtPart (xbString &sFileExtPartOut) const
 Get the extension part of the file name. More...
 
xbInt16 GetFileExtPart (const xbString &sCompleteFileNameIn, xbString &sFileExtPartOut) const
 Get the extension part of the file name. More...
 
xbInt16 GetFileMtime (time_t &mtime)
 Get the time of last file modification timestamp as reported by the OS. More...
 
xbInt16 GetFileNamePart (xbString &sFileNamePartOut) const
 Get the name part of the file name. More...
 
xbInt16 GetFileNamePart (const xbString &sCompleteFileNameIn, xbString &sFileNamePartOut) const
 Get the name part of the file name. More...
 
xbInt16 GetFileSize (xbUInt64 &ullFileSize)
 Get the size of the file as reported by the OS. More...
 
xbInt16 GetFileType (xbString &sFileType) const
 Get the file type aka Capitalized file extension. More...
 
xbInt16 GetOpenMode () const
 Get the open mode of the file. More...
 
xbInt16 GetShareMode () const
 Get the share mode of the file. More...
 
xbInt16 GetXbaseFileTypeByte (const xbString &sFileName, xbInt16 &iVersion)
 Get the file type byte and version of the dbf file. More...
 
xbInt16 GetXbaseFileTypeByte (const xbString &sFileName, unsigned char &cFileTypeByte)
 Get the file type byte and version of the dbf file. More...
 
xbInt16 GetXbaseFileTypeByte (const xbString &sFileName, unsigned char &cFileTypeByte, xbInt16 &iVersion)
 Get the file type byte and version of the dbf file. More...
 
xbInt16 NameSuffixMissing (const xbString &sFileName, xbInt16 iOption) const
 Determines status of file extension. More...
 
xbInt16 ReadBlock (xbUInt32 ulBlockNo, size_t readSize, void *buf)
 Read a block of data from file. More...
 
xbInt16 ReadBlock (xbUInt32 ulBlockNo, xbUInt32 ulBlockSize, size_t readSize, void *buf)
 Read a block of data from file. More...
 
xbInt16 SetBlockSize (xbUInt32 ulBlockSize)
 Set the block size. More...
 
void SetDirectory (const xbString &sDirectory)
 Set the directory. More...
 
void SetFileName (const xbString &sFileName)
 Set the filename. More...
 
void SetFqFileName (const xbString &sFqName)
 Set the fully qualifed filename. More...
 
xbInt16 SetHomeFolders ()
 Set Home Folders. More...
 
xbInt16 WriteBlock (xbUInt32 ulBlockNo, size_t writeSize, void *buf)
 Write a block of data to file. More...
 
xbInt16 xbFclose ()
 Xbase wrapper for standard libary fclose. More...
 
xbInt16 xbFeof ()
 Xbase wrapper for standard libary feof. More...
 
xbInt16 xbFflush ()
 Xbase wrapper for standard libary fflush. More...
 
xbInt16 xbFgetc (xbInt32 &c)
 Xbase wrapper for standard libary fgetc. More...
 
xbInt16 xbFgetc (char &c)
 Xbase wrapper for standard libary fgetc. More...
 
xbInt16 xbFgets (size_t lSize, xbString &sLine)
 Xbase wrapper for standard libary fgets. More...
 
xbInt16 xbFopen (xbInt16 iOpenMode)
 
xbInt16 xbFopen (const xbString &sOpenMode, xbInt16 iShareMode)
 Xbase wrapper for standard libary fopen. More...
 
xbInt16 xbFopen (xbInt16 iOpenMode, xbInt16 iShareMode)
 Xbase wrapper for standard libary fopen. More...
 
xbInt16 xbFopen (const xbString &sMode, const xbString &sFileName, xbInt16 iShareMode)
 Xbase wrapper for standard libary fopen. More...
 
xbInt16 xbFputc (xbInt32 c)
 Xbase wrapper for standard libary fputc. More...
 
xbInt16 xbFputc (xbInt32 c, xbInt32 iNoTimes)
 Xbase wrapper for standard libary fputc. More...
 
xbInt16 xbFputs (const xbString &s)
 Xbase wrapper for standard libary fputs. More...
 
xbInt16 xbFread (void *ptr, size_t size, size_t nmemb)
 Xbase wrapper for standard libary fread. More...
 
xbInt16 xbFseek (xbInt64 llOffset, xbInt32 whence)
 Xbase wrapper for standard libary fseek. More...
 
size_t xbFtell ()
 Xbase wrapper for standard libary ftell. More...
 
void xbFTurnOffFileBuffering ()
 Turn off file buffering. More...
 
xbInt16 xbReadUntil (const char cDelim, xbString &sOut)
 Read file until a particular character is encountered on input stream. More...
 
xbInt16 xbRemove (const xbString &sFileName, xbInt16 iOption)
 Delete file. More...
 
xbInt16 xbRemove (const xbString &sFileName)
 Delete file. More...
 
xbInt16 xbRemove ()
 Delete file. More...
 
xbInt16 xbRename (const xbString &sOldName, const xbString &sNewName)
 Rename file. More...
 
void xbRewind ()
 Xbase wrapper for rewind. More...
 
xbInt16 xbFwrite (const void *ptr, size_t lSize, size_t lNmemb)
 Xbase wrapper for standard libary fwrite. More...
 
xbInt16 xbTruncate (xbInt64 llSize)
 Xbase wrapper for ftruncate. More...
 
void DisplayError (xbInt16 ErrorCode) const
 Display error message on console for a given error number. More...
 
xbStringGetDefaultDateFormat () const
 Get the default date format. More...
 
xbStringGetDataDirectory () const
 Get the current data directory. More...
 
xbStringGetTempDirectory () const
 Get the current temp directory. More...
 
void GetHomeDir (xbString &sHomeDirOut)
 Get home directory. More...
 
xbInt16 GetEndianType () const
 Get the Endian type. More...
 
const char * GetErrorMessage (xbInt16 ErrorCode) const
 Get an error message. More...
 
char GetPathSeparator () const
 Get the OS dependent path separator. More...
 
void SetDataDirectory (const xbString &sDataDirectory)
 Set the data directory. More...
 
void SetDefaultDateFormat (const xbString &sDefaultDateFormat)
 Set the default date format. More...
 
void SetTempDirectory (const xbString &sTempDirectory)
 Set the temp directory. More...
 
xbBool BitSet (unsigned char c, xbInt16 iBitNo) const
 Check a bit in a one byte field and see if it is set. More...
 
void BitDump (unsigned char c) const
 
void BitDump (char c) const
 
xbBool GetDefaultAutoCommit () const
 Get the default auto commit setting. More...
 
void SetDefaultAutoCommit (xbBool bDefaultAutoCommit)
 Set the default auto commit. More...
 
xbStringGetLogDirectory () const
 
xbStringGetLogFileName () const
 
void SetLogDirectory (const xbString &sLogDirectory)
 
void SetLogFileName (const xbString &sLogFileName)
 
xbBool GetMultiUser () const
 Get the multi user setting. More...
 
void SetMultiUser (xbBool bMultiUser)
 Get the multi user setting. More...
 

Static Public Attributes

static const char * ErrorCodeText []
 

Protected Member Functions

void SetEndianType ()
 Set the endian type. More...
 

Protected Attributes

xbXBasexbase
 

Static Protected Attributes

static xbInt16 iEndianType = 0
 
static xbString sNullString = ""
 

Detailed Description

Class for handling low level file I/O.

The xbFile class is used as an abstraction layer to isolate the library from the nuances of different operating systems and machine architectures.

This module handles low level file I/O and is a base class for the (dbf) table, (dbt) memo and (ndx,mdx) index classes. Files are opened and manipulated via methods in the xbFile class.
This class handles:
1) Big and little endian reads/writes
2) 32 or 64 bit system calls, depending on OS
3) Various different c/c++ calls to open/close/read/write based on OS and compiler version

If you are wanting to port this library to a new platform, start with this class. This class could be used if you want to write a platform independent program that needs R/W file access.

Constructor & Destructor Documentation

◆ xbFile()

xb::xbFile::xbFile ( xbXBase x)

Class Constructor.

◆ ~xbFile()

xb::xbFile::~xbFile ( )

Class Destructor.

Member Function Documentation

◆ BitDump() [1/2]

void xb::xbSsv::BitDump ( char  c) const
inherited

◆ BitDump() [2/2]

void xb::xbSsv::BitDump ( unsigned char  c) const
inherited

◆ BitSet()

xbBool xb::xbSsv::BitSet ( unsigned char  c,
xbInt16  iBitNo 
) const
inherited

Check a bit in a one byte field and see if it is set.

Parameters
cOne byte char field to examine.
iBitNowhich bit to examine.
Returns
xbTrue Bit is set
xbFalse Bit is not set

◆ CreateUniqueFileName()

xbInt16 xb::xbFile::CreateUniqueFileName ( const xbString sDirIn,
const xbString sExtIn,
xbString sFqnOut,
xbInt16  iOption = 0 
)

Create a unique file name.

Given a directory and file extension as inputs, create a unique file name.

Parameters
sDirInDirectory
sExtInFile Extension
sFqnOutA fully qualifed unique file name as output
Returns
Return Codes

Create a unique file name.

Given a directory and file extension as inputs, create a unique file name.

Parameters
sDirInDirectory
sExtInFile Extension
iOption0 - look only for one file for a given directory and extension
1 - if file name extension is "dbf" or "DBF", verify unique dbt or DBT (memo) file is also available
sFqnOutA fully qualifed unique file name as output
Returns
Return Codes

◆ DetermineXbaseMemoVersion()

xbInt16 xb::xbFile::DetermineXbaseMemoVersion ( unsigned char  cFileTypeByte) const

Determine which version the memo (dbt) file is.

This routine uses the first byte in the dbf file to determine which memo file version is in use. The main difference between version 3 and 4 is that version 4 will reuse blocks if they become available. Version 3 does not.

Parameters
cFileTypeByteis an output field and is one of:

0 - none
3 - Dbase III+
4 - Dbase IV
Returns
Return Codes

◆ DetermineXbaseTableVersion()

xbInt16 xb::xbFile::DetermineXbaseTableVersion ( unsigned char  cFileTypeByte) const

Determine xbase dbf version.

This routine is used to determine which version of the Xbase classes can be used for a given DBF file.

It attempts to use the highest version compiled into the library.

References:
This routine uses the first byte from the dbf file.
Per DBase documentation:
Valid dBASE for Windows table file, bits 0-2 indicate version number: 3 for dBASE Level 5, 4 for dBASE Level 7.
Bit 3 and bit 7 indicate presence of a dBASE IV or dBASE for Windows memo file;
Bits 4-6 indicate the presence of a dBASE IV SQL table;
Bit 7 indicates the presence of any .DBT memo file (either a dBASE III PLUS type or a dBASE IV or dBASE for Windows memo file).

Bachmann spec (used extensively in library build), page 7 - does not match DBase documentation

returns
0 - unknown
3 - Dbase level 3
4 - Dbase level 4
5 - Dbase Level 5 (future)
7 - Dbase Level 7 (future)

1x - Clipper files (future)
2x - Foxbase files (future)

◆ DisplayError()

void xb::xbSsv::DisplayError ( xbInt16  iErrorCode) const
inherited

Display error message on console for a given error number.

Parameters
iErrorCodeError number to reference

◆ eGetDouble()

xbDouble xb::xbFile::eGetDouble ( const char *  p) const

Get a portable double value.

This routine returns a double value from an 8 byte character stream, accounting for endian type.

Converts a double (64 bit floating point) value stored at p from a portable format to the machine format.

Parameters
ppointer to memory containing the portable double value
Returns
the double value.

◆ eGetInt16()

xbInt16 xb::xbFile::eGetInt16 ( const char *  p) const

Get a portable short value.

This routine returns a short int value from a 2 byte character stream, accounting for endian type.

Parameters
ppointer to memory containing the portable long value
Returns
the short value.

◆ eGetInt32()

xbInt32 xb::xbFile::eGetInt32 ( const char *  p) const

Get a portable long value.

This routine returns a long int value from a 4 byte character stream, accounting for endian type.

Parameters
ppointer to memory containing the portable long value
Returns
the long value.

◆ eGetUInt16()

xbUInt16 xb::xbFile::eGetUInt16 ( const char *  p) const

Get a portable unsigned short value.

This routine returns a short unsigned int value from a 2 byte character stream, accounting for endian type.

Parameters
ppointer to memory containing the portable long value
Returns
the short value.

◆ eGetUInt32()

xbUInt32 xb::xbFile::eGetUInt32 ( const char *  p) const

Get a portable unsigned long value.

This routine returns an unsigned long int value from a 4 byte character stream, accounting for endian type.

Parameters
ppointer to memory containing the portable long value
Returns
the unsigned long value.

◆ ePutDouble()

void xb::xbFile::ePutDouble ( char *  c,
xbDouble  d 
)

Write a portable double value to memory location.

Converts a double (64 bit floating point) value from machine format to a portable format and stores the converted value in the memory referenced by c.

This routine puts a double value to an 8 byte character stream

Parameters
cPointer to memory to hold converted value
dInput value to be converted

◆ ePutInt16()

void xb::xbFile::ePutInt16 ( char *  c,
xbInt16  s 
)

Write a portable short value to memory location.

Converts a short (16 bit integer) value from machine format to a portable format and stores the converted value in the memory referenced by c.

This routine puts a short value to a 2 byte character stream

Parameters
cPointer to memory to hold converted value
sInput value to be converted

◆ ePutInt32()

void xb::xbFile::ePutInt32 ( char *  c,
xbInt32  l 
)

Write a portable long value to memory location.

Converts a long (32 bit integer) value from machine format to a portable format and stores the converted value in the memory referenced by c.

This routine puts a long value to a 4 byte character stream.

Parameters
cPointer to memory to hold converted value
lInput value to be converted

◆ ePutUInt16()

void xb::xbFile::ePutUInt16 ( char *  c,
xbUInt16  s 
)

Write a portable unsigned short value to memory location.

Converts an unsigned short (16 bit integer) value from machine format to a portable format and stores the converted value in the memory referenced by c.

This routine puts an unsigned short value to a 2 byte character stream

Parameters
cPointer to memory to hold converted value
sInput value to be converted

◆ ePutUInt32()

void xb::xbFile::ePutUInt32 ( char *  c,
xbUInt32  ul 
)

Write a portable unsigned long value to memory location.

Converts an unsigned long (32 bit integer) value from machine format to a portable format and stores the converted value in the memory referenced by c.

This routine puts an unsigned long value to a 4 byte character stream.

Parameters
cPointer to memory to hold converted value
ulInput value to be converted

◆ FileExists() [1/4]

xbBool xb::xbFile::FileExists ( ) const

Determines if a file exists.

Returns
xbTrue if file exists
xbFalse if file does not exist

◆ FileExists() [2/4]

xbBool xb::xbFile::FileExists ( const xbString sFileName) const

Determines if a file exists.

Parameters
sFileName- file name to check for
Returns
xbTrue if file exists
xbFalse if file does not exist

◆ FileExists() [3/4]

xbBool xb::xbFile::FileExists ( const xbString sFileName,
xbInt16  iOption 
) const

Determines if a file exists.

Parameters
sFileName- file name to check for
iOptionif 1, assume this is a request for a dbf file and check for the a dbt memo file also, returns true if both files are found
Returns
xbTrue if both dbf and dbt files exist
xbFalse if file does not exist

◆ FileExists() [4/4]

xbBool xb::xbFile::FileExists ( xbInt16  iOption) const

Determines if a file exists.

Parameters
iOptionif 1, assume this is a request for a dbf file and check for the a dbt memo file also, returns true if both files are found
Returns
xbTrue if both files exist
xbFalse if file does not exist

◆ FileIsOpen()

xbBool xb::xbFile::FileIsOpen ( ) const

Determines if file is open.

Returns
xbTrue if file is open
xbFalse if file is not open

◆ GetBlockSize()

xbUInt32 xb::xbFile::GetBlockSize ( ) const

Get the block size.

Returns
Block Size

◆ GetDataDirectory()

xbString & xb::xbSsv::GetDataDirectory ( ) const
inherited

Get the current data directory.

Returns
xbString containing the current data directory where the database files are stored.

◆ GetDefaultAutoCommit()

xbBool xb::xbSsv::GetDefaultAutoCommit ( ) const
inherited

Get the default auto commit setting.

When auto commit is enabled, the library will automatically post any updates when moving off an updated record or closing files. If auto commit is disabled, the application program will need to explicitly update the tables using using dbf->Put() and dbf->AppendRecord().

Returns
xbTrue if auto commit is turned on
xbFalse is auto commit is turned off

◆ GetDefaultDateFormat()

xbString & xb::xbSsv::GetDefaultDateFormat ( ) const
inherited

Get the default date format.

Returns
xbString containing the default date format.

◆ GetDirectory()

const xbString & xb::xbFile::GetDirectory ( ) const

Get the directory name.

Returns
the directory name of the file

◆ GetEndianType()

xbInt16 xb::xbSsv::GetEndianType ( ) const
inherited

Get the Endian type.

Returns
B - Big endian
L - Little endian

◆ GetErrorMessage()

const char * xb::xbSsv::GetErrorMessage ( xbInt16  iErrorCode) const
inherited

Get an error message.

Parameters
iErrorCodeErrorCode is the error number of description to be returned.
Returns
Returns a pointer to a string containing a text description for the error code.

◆ GetFileDirPart() [1/2]

xbInt16 xb::xbFile::GetFileDirPart ( const xbString sCompleteFileNameIn,
xbString sFileDirPartOut 
) const

Get the directory part of the file name.

Parameters
sCompleteFileNameIn- a fully qualfied input file name
sFileDirPartOut- the returned directory name part out of sCompleteFileNameIn
Returns
Return Codes

◆ GetFileDirPart() [2/2]

xbInt16 xb::xbFile::GetFileDirPart ( xbString sFileDirPartOut) const

Get the directory part of the file name.

Parameters
sFileDirPartOut- the returned directory name
Returns
Return Codes

◆ GetFileExtPart() [1/2]

xbInt16 xb::xbFile::GetFileExtPart ( const xbString sCompleteFileNameIn,
xbString sFileExtPartOut 
) const

Get the extension part of the file name.

Parameters
sCompleteFileNameIn- a fully qualfied input file name
sFileExtPartOut- the returned directory name part out of sCompleteFileNameIn
Returns
Return Codes

◆ GetFileExtPart() [2/2]

xbInt16 xb::xbFile::GetFileExtPart ( xbString sFileNameExtOut) const

Get the extension part of the file name.

Parameters
sFileNameExtOut- the returned extension part out of sCompleteFileNameIn
Returns
Return Codes

◆ GetFileMtime()

xbInt16 xb::xbFile::GetFileMtime ( time_t &  mtime)

Get the time of last file modification timestamp as reported by the OS.

Parameters
mtime- returned time of last file modification
Returns
Return Codes

◆ GetFileName()

const xbString & xb::xbFile::GetFileName ( ) const

Get the file name.

Returns
the file name portion of the file

◆ GetFileNamePart() [1/2]

xbInt16 xb::xbFile::GetFileNamePart ( const xbString sCompleteFileNameIn,
xbString sFileNamePartOut 
) const

Get the name part of the file name.

Parameters
sCompleteFileNameIn- a fully qualified input file name
sFileNamePartOut- the returned file name part out of sCompleteFileNameIn
Returns
Return Codes

◆ GetFileNamePart() [2/2]

xbInt16 xb::xbFile::GetFileNamePart ( xbString sFileNamePartOut) const

Get the name part of the file name.

Parameters
sFileNamePartOut- the returned file name part out of sCompleteFileNameIn
Returns
Return Codes

◆ GetFileSize()

xbInt16 xb::xbFile::GetFileSize ( xbUInt64 &  ullFileSize)

Get the size of the file as reported by the OS.

Parameters
ullFileSize- unsigned long long field as output
Returns
Return Codes

◆ GetFileType()

xbInt16 xb::xbFile::GetFileType ( xbString sFileTypeOut) const

Get the file type aka Capitalized file extension.

Parameters
sFileTypeOut- the returned extension part out of sCompleteFileNameIn
Returns
Return Codes

◆ GetFqFileName()

const xbString & xb::xbFile::GetFqFileName ( ) const

Get the fully qualified file name.

Returns
the fully qualfied name of the file

◆ GetHomeDir()

void xb::xbSsv::GetHomeDir ( xbString sHomeDirOut)
inherited

Get home directory.

Parameters
sHomeDirOut- Output home directory for current user.

◆ GetLogDirectory()

xbString & xb::xbSsv::GetLogDirectory ( ) const
inherited

◆ GetLogFileName()

xbString & xb::xbSsv::GetLogFileName ( ) const
inherited

◆ GetMultiUser()

xbBool xb::xbSsv::GetMultiUser ( ) const
inherited

Get the multi user setting.

Returns
xbTrue - Multi user mode turned on.
xbFalse - Multi user mode turned off.

◆ GetOpenMode()

xbInt16 xb::xbFile::GetOpenMode ( ) const

Get the open mode of the file.

Returns
XB_READ
XB_READ_WRITE
XB_WRITE

◆ GetPathSeparator()

char xb::xbSsv::GetPathSeparator ( ) const
inherited

Get the OS dependent path separator.

Returns
Returns '\' for windows environment, otherwise returns '/'.

◆ GetShareMode()

xbInt16 xb::xbFile::GetShareMode ( ) const

Get the share mode of the file.

Returns
XB_SINGLE_USER - (file buffering on>
XB_MULTI_USER - (file buffering off)

◆ GetTempDirectory()

xbString & xb::xbSsv::GetTempDirectory ( ) const
inherited

Get the current temp directory.

Returns
xbString containing the current data directory where the database files are stored.

◆ GetXbaseFileTypeByte() [1/3]

xbInt16 xb::xbFile::GetXbaseFileTypeByte ( const xbString sFileName,
unsigned char &  cFileTypeByte 
)

Get the file type byte and version of the dbf file.

Pull the first bye off the DBF file for further inspection. First byte has various bits set to determine what the file format is.

Parameters
sFileName- Name of file to examine
cFileTypeByte- Retruned first byte of dbf file
Returns
Return Codes

◆ GetXbaseFileTypeByte() [2/3]

xbInt16 xb::xbFile::GetXbaseFileTypeByte ( const xbString sFileName,
unsigned char &  cFileTypeByte,
xbInt16 &  iVersion 
)

Get the file type byte and version of the dbf file.

Pull the first bye off the DBF file for further inspection. First byte has various bits set to determine what the file format is.

Parameters
sFileName- Name of file to examine
cFileTypeByte- Returned first byte of dbf file
iVersion- Returned file version
Returns
Return Codes

◆ GetXbaseFileTypeByte() [3/3]

xbInt16 xb::xbFile::GetXbaseFileTypeByte ( const xbString sFileName,
xbInt16 &  iVersion 
)

Get the file type byte and version of the dbf file.

Pull the first bye off the DBF file for further inspection. First byte has various bits set to determine what the file format is.

Parameters
sFileName- Name of file to examine
iVersion- Returned file version
Returns
Return Codes

◆ NameSuffixMissing()

xbInt16 xb::xbFile::NameSuffixMissing ( const xbString sFileName,
xbInt16  iOption 
) const

Determines status of file extension.

Parameters
sFileName- Name of file to examine
iOption- Inspection type
1 check for DBF
2 check for NDX
3 check for MDX
4 check for NTX
Returns
0 if suffix found
1 if suffix not found, lower case
2 is suffix not found, upper case

◆ ReadBlock() [1/2]

xbInt16 xb::xbFile::ReadBlock ( xbUInt32  ulBlockNo,
size_t  lReadSize,
void *  buf 
)

Read a block of data from file.

Parameters
ulBlockNo- block number to read
lReadSize- size of data to read at block location, set to 0 to read blocksize
*buf- pointer to buffer to write output data, assumed to be previosuly allocated and large enough to contain data
Returns
Return Codes

◆ ReadBlock() [2/2]

xbInt16 xb::xbFile::ReadBlock ( xbUInt32  ulBlockNo,
xbUInt32  ulBlockSize,
size_t  lReadSize,
void *  buf 
)

Read a block of data from file.

Parameters
ulBlockNo- block number to read
ulBlockSize- block size
lReadSize- size of data to read at block location, set to 0 to read blocksize
buf- pointer to buffer to write output data, assumed to be previosuly allocated and large enough to contain data
Returns
Return Codes

◆ SetBlockSize()

xbInt16 xb::xbFile::SetBlockSize ( xbUInt32  ulBlockSize)

Set the block size.

Parameters
ulBlockSize- unsigned long block size, divisible by 512
Returns
Return Codes

◆ SetDataDirectory()

void xb::xbSsv::SetDataDirectory ( const xbString sDataDirectory)
inherited

Set the data directory.

Parameters
sDataDirectorySet the data directory.

◆ SetDefaultAutoCommit()

void xb::xbSsv::SetDefaultAutoCommit ( xbBool  bDefaultAutoCommit)
inherited

Set the default auto commit.

Disabling auto commit requires the application execute explicit updates using dbf->Put() and dbf->AppendRecord(). With auto commit on, the library posts updates automatically when moving off the current record or closing a file.

Parameters
bDefaultAutoCommitxbTrue - Enable default auto commit.
xbFalse - Disable default auto commit.

◆ SetDefaultDateFormat()

void xb::xbSsv::SetDefaultDateFormat ( const xbString sDefaultDateFormat)
inherited

Set the default date format.

Parameters
sDefaultDateFormatSet the default date format.

◆ SetDirectory()

void xb::xbFile::SetDirectory ( const xbString sDirectory)

Set the directory.

Parameters
sDirectory- Valid directory name

◆ SetEndianType()

void xb::xbSsv::SetEndianType ( )
protectedinherited

Set the endian type.

This routine determines the Endian-ness at run time instead of compile time as some processers (ie; Sparc,ARM) can be switched either way. This routine is called automatically by the library at startup and does not need to be called in an application program.

◆ SetFileName()

void xb::xbFile::SetFileName ( const xbString sFileName)

Set the filename.

This routine builds out two internal variables from the input file name
sFileName - the file name part
sFqFileName - the fully qualified file name

Parameters
sFileName- Input file name

◆ SetFqFileName()

void xb::xbFile::SetFqFileName ( const xbString sFqFileName)

Set the fully qualifed filename.

Parameters
sFqFileName- Fully qualifed input file name

◆ SetHomeFolders()

xbInt16 xb::xbFile::SetHomeFolders ( )

Set Home Folders.

Create xbase64 log, data and temp folders in the home directory for current usre.

Returns
Return Codes

◆ SetLogDirectory()

void xb::xbSsv::SetLogDirectory ( const xbString sLogDirectory)
inherited

◆ SetLogFileName()

void xb::xbSsv::SetLogFileName ( const xbString sLogFileName)
inherited

◆ SetMultiUser()

void xb::xbSsv::SetMultiUser ( xbBool  bMultiUser)
inherited

Get the multi user setting.

Parameters
bMultiUserxbTrue - Turn on Multi user mode.
xbFalse - Turn off Multi user mode.

◆ SetTempDirectory()

void xb::xbSsv::SetTempDirectory ( const xbString sTempDirectory)
inherited

Set the temp directory.

Parameters
sTempDirectorySet the data direcroty.

◆ WriteBlock()

xbInt16 xb::xbFile::WriteBlock ( xbUInt32  ulBlockNo,
size_t  lWriteSize,
void *  buf 
)

Write a block of data to file.

Parameters
ulBlockNo- block number to write
lWriteSize- size of data to write, set to 0 to write blocksize
*buf- pointer to buffer of data to be written
Returns
Return Codes

◆ xbFclose()

xbInt16 xb::xbFile::xbFclose ( )

Xbase wrapper for standard libary fclose.

Returns
Return Codes

◆ xbFeof()

xbInt16 xb::xbFile::xbFeof ( )

Xbase wrapper for standard libary feof.

Returns
non zero if end-of-file is set for the stream.

◆ xbFflush()

xbInt16 xb::xbFile::xbFflush ( )

Xbase wrapper for standard libary fflush.

Returns
Return Codes

◆ xbFgetc() [1/2]

xbInt16 xb::xbFile::xbFgetc ( char &  c)

Xbase wrapper for standard libary fgetc.

Parameters
c- output character returned by fgetc
Returns
Return Codes

◆ xbFgetc() [2/2]

xbInt16 xb::xbFile::xbFgetc ( xbInt32 &  c)

Xbase wrapper for standard libary fgetc.

Parameters
c- output integer returned by fgetc
Returns
Return Codes

◆ xbFgets()

xbInt16 xb::xbFile::xbFgets ( size_t  lSize,
xbString s 
)

Xbase wrapper for standard libary fgets.

Parameters
lSize- reads in at most, one character less than lSize
s- an xbString containing data returned by fseek
Returns
Return Codes

◆ xbFopen() [1/4]

xbInt16 xb::xbFile::xbFopen ( const xbString sOpenMode,
const xbString sFileName,
xbInt16  iShareMode 
)

Xbase wrapper for standard libary fopen.

This routine supports all the standard C library open modes. The Xbase routines only use "r" and "r+b".

Parameters
sOpenMode
OpenModeDescription
rReading
r+Reading and Writing
wOpen for writing. Truncate to zero bytes if it exists
w+Open for reading and writing, truncate to zero bytes if it exists
aOpen for append
a+Open for reading and writing (at end).
The mode can also include the letter "b" for binary ie; "r+b". The "b" is ignored on POSIX compliant systems, but is included for cross platform compatibility.
sFileNameFile name to open
iShareModeXB_SINGLE_USER
XB_MULTI_USER
Returns
Return Codes

◆ xbFopen() [2/4]

xbInt16 xb::xbFile::xbFopen ( const xbString sOpenMode,
xbInt16  iShareMode 
)

Xbase wrapper for standard libary fopen.

This routine supports all the standard C library open modes. The Xbase routines only use "r" and "r+".

Parameters
sOpenMode
OpenModeDescription
rReading
r+Reading and Writing
wOpen for writing. Truncate to zero bytes if it exists
w+Open for reading and writing, truncate to zero bytes if it exists
aOpen for append
a+Open for reading and writing (at end).
The mode can also include the letter "b" for binary ie; "r+b". The "b" is ignored on POSIX compliant systems, but is included for cross platform compatibility.
iShareModeXB_SINGLE_USER
XB_MULTI_USER
Returns
Return Codes

◆ xbFopen() [3/4]

xbInt16 xb::xbFile::xbFopen ( xbInt16  iOpenMode)

◆ xbFopen() [4/4]

xbInt16 xb::xbFile::xbFopen ( xbInt16  iOpenMode,
xbInt16  iShareMode 
)

Xbase wrapper for standard libary fopen.

Parameters
iOpenModeXB_READ
XB_READ_WRITE
iShareModeXB_SINGLE_USER
XB_MULTI_USER
Returns
Return Codes

◆ xbFputc() [1/2]

xbInt16 xb::xbFile::xbFputc ( xbInt32  c)

Xbase wrapper for standard libary fputc.

Parameters
cCharacter to write
Returns
Return Codes

◆ xbFputc() [2/2]

xbInt16 xb::xbFile::xbFputc ( xbInt32  c,
xbInt32  iNoOfTimes 
)

Xbase wrapper for standard libary fputc.

Parameters
cCharacter to write
iNoOfTimesNumber of times to write the character
Returns
Return Codes

◆ xbFputs()

xbInt16 xb::xbFile::xbFputs ( const xbString s)

Xbase wrapper for standard libary fputs.

Parameters
sxbString to write to file
Returns
Return Codes

◆ xbFread()

xbInt16 xb::xbFile::xbFread ( void *  p,
size_t  size,
size_t  nmemb 
)

Xbase wrapper for standard libary fread.

Parameters
pPointer to data to write
sizesize of write
nmembNumber of times to read it
Returns
Return Codes

◆ xbFseek()

xbInt16 xb::xbFile::xbFseek ( xbInt64  lOffset,
xbInt32  iWhence 
)

Xbase wrapper for standard libary fseek.

Parameters
lOffsetPosition in file to seek to
iWhenceSEEK_SET - from beginning of file
SEEK_CUR - from current position
SEEK_END - from end of file
Returns
Return Codes

◆ xbFtell()

size_t xb::xbFile::xbFtell ( )

Xbase wrapper for standard libary ftell.

Returns the current file position.

Returns
Current file position.

◆ xbFTurnOffFileBuffering()

void xb::xbFile::xbFTurnOffFileBuffering ( )

Turn off file buffering.

Turns off file buffering. File buffering can't be used while in multi user mode.

◆ xbFwrite()

xbInt16 xb::xbFile::xbFwrite ( const void *  p,
size_t  size,
size_t  nmemb 
)

Xbase wrapper for standard libary fwrite.

Parameters
pPointer to data buffer to write
sizeSize of data to write
nmembNumber of times to write data buffer
Returns
Return Codes

◆ xbReadUntil()

xbInt16 xb::xbFile::xbReadUntil ( const char  cDelim,
xbString sOut 
)

Read file until a particular character is encountered on input stream.

This routine will read until cDelim is encountered or eof, which ever occurs first.

Parameters
cDelimDelimiter to stop writing at.
sOutOutput xbString containing data read
Returns
Return Codes

◆ xbRemove() [1/3]

xbInt16 xb::xbFile::xbRemove ( )

Delete file.

Returns
Return Codes

◆ xbRemove() [2/3]

xbInt16 xb::xbFile::xbRemove ( const xbString sFileNameIn)

Delete file.

Parameters
sFileNameInName of file to delete
Returns
Return Codes

◆ xbRemove() [3/3]

xbInt16 xb::xbFile::xbRemove ( const xbString sFileNameIn,
xbInt16  iOption 
)

Delete file.

Parameters
sFileNameInName of file to delete
iOptionIf Set to 1, assume this is a delete request for a dbf file, and should rename the dbt file also
Returns
Return Codes

◆ xbRename()

xbInt16 xb::xbFile::xbRename ( const xbString sOldName,
const xbString sNewName 
)

Rename file.

Parameters
sOldNameOriginal file name
sNewNameNew file name
Returns
Return Codes

◆ xbRewind()

void xb::xbFile::xbRewind ( )

Xbase wrapper for rewind.

Set file pointer at beginning of file.

◆ xbTruncate()

xbInt16 xb::xbFile::xbTruncate ( xbInt64  llSize)

Xbase wrapper for ftruncate.

Set file size to llSize

Parameters
llSizeNew file size.
Returns
Return Codes

Field Documentation

◆ ErrorCodeText

const char* xb::xbSsv::ErrorCodeText[]
staticinherited

◆ iEndianType

xbInt16 xb::xbSsv::iEndianType = 0
staticprotectedinherited

◆ sNullString

xbString xb::xbSsv::sNullString = ""
staticprotectedinherited

◆ xbase

xbXBase* xb::xbFile::xbase
protected

The documentation for this class was generated from the following files: