diff options
Diffstat (limited to 'src/core/xbxbase.cpp')
-rwxr-xr-x | src/core/xbxbase.cpp | 78 |
1 files changed, 66 insertions, 12 deletions
diff --git a/src/core/xbxbase.cpp b/src/core/xbxbase.cpp index 20b7fcc..7267f98 100755 --- a/src/core/xbxbase.cpp +++ b/src/core/xbxbase.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +Copyright (c) 1997,2003,2014,2022,2023 Gary A Kunkel The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. @@ -21,13 +21,13 @@ namespace xb{ //! @brief Class Constructor. xbXBase::xbXBase() { SetEndianType(); - #ifdef XB_LOGGING_SUPPORT - xLog = new xbLog(); - #endif xbFile f( this ); f.SetHomeFolders(); - + xbDate d( (xbUInt16) 1); // initialize xbDate static variables + #ifdef XB_LOGGING_SUPPORT + xLog = new xbLog(); + #endif } /*************************************************************************/ //! @brief Class Deconstructor. @@ -37,11 +37,10 @@ xbXBase::~xbXBase(){ delete xLog; #endif } - /*************************************************************************/ //! @brief Close all tables / files. /*! - This closes everything. + This closes everything and deletes references to the associated xbDbf objects. \returns <a href="xbretcod_8h.html">Return Codes</a> */ xbInt16 xbXBase::CloseAllTables(){ @@ -58,6 +57,7 @@ xbInt16 xbXBase::CloseAllTables(){ iErrorStop = 100; throw iRc; } + delete d; } else { iRc = XB_INVALID_OBJECT; iErrorStop = 110; @@ -74,7 +74,39 @@ xbInt16 xbXBase::CloseAllTables(){ return iRc; } +/************************************************************************/ +//! @brief Fully qualified file name from a directory, filename and extension. +/*! + Given a directory, file name and file extension as inputs, create a fully qualified file name. + \param sDirIn Directory + \param sFileIn File Name + \param sExtIn File Extension + \param sFqnOut A fully qualifed unique file name as output + \returns XB_INVALIED_PARAMETER or XB_NO_ERROR +*/ +xbInt16 xbXBase::CreateFqn( const xbString &sDirIn, const xbString &sNameIn, const xbString &sExtIn, xbString &sFqnOut ){ + + if( sNameIn == "" || sExtIn == "" ) + return XB_INVALID_PARAMETER; + + sFqnOut = sDirIn; + #ifdef WIN32 + sFqnOut.SwapChars( '/', '\\' ); + if( sFqnOut[sFqnOut.Len()] != '\\' ) + sFqnOut += '\\'; + #else + sFqnOut.SwapChars( '\\', '/' ); + if( sFqnOut[sFqnOut.Len()] != '/' ) + sFqnOut += '/'; + #endif + sFqnOut += sNameIn; + if( sExtIn != "" ){ + sFqnOut += '.'; + sFqnOut += sExtIn; + } + return XB_NO_ERROR; +} /*************************************************************************/ //! @brief Parse commmand line options for a given parm request @@ -134,18 +166,21 @@ const xbString & xbXBase::GetLogFqFileName() const { /*! \returns Returns the log file name. */ +/* const xbString & xbXBase::GetLogFileName() const { return xLog->GetFileName(); } +*/ //! @brief Get the log directory. /*! \returns Returns the log directory. */ +/* const xbString & xbXBase::GetLogDirectory() const { - return xLog->GetDirectory(); + return GetLogDirectory(); } - +*/ //! @brief Get the log directory. /*! \returns xbTrue - Logging enabled.<br>xbFalse - Logging disables. @@ -159,19 +194,23 @@ xbBool xbXBase::GetLogStatus() const { \param sLogFileName - Log File Name. \return void */ +/* void xbXBase::SetLogFileName( const xbString & sLogFileName ){ xLog->SetFileName( sLogFileName ); } - +*/ //! @brief Set the log directory. /*! \param sLogDirectory - Log File Directory. \return void */ +/* void xbXBase::SetLogDirectory( const xbString & sLogDirectory ){ xLog->SetDirectory( sLogDirectory ); } +*/ + //! @brief Set the logfile size. /*! @@ -182,6 +221,15 @@ void xbXBase::SetLogSize( size_t lSize ) { xLog->LogSetLogSize( lSize ); } +//! @brief Get the logfile size. +/*! + \return log file size +*/ +size_t xbXBase::GetLogSize() const { + return xLog->LogGetLogSize(); +} + + //! @brief Write message to logfile. /*! \param sLogMessage - Message to write. @@ -225,18 +273,22 @@ xbInt16 xbXBase::FlushLog() { const xbString & xbXBase::GetLogFqFileName() const { return sNullString; } +/* const xbString & xbXBase::GetLogFileName() const { return sNullString; } const xbString & xbXBase::GetLogDirectory() const { return sNullString; } +*/ +/* void xbXBase::SetLogFileName( const xbString & sLogFileName ){ return; } void xbXBase::SetLogDirectory( const xbString & sLogDirectory ){ return; } +*/ xbBool xbXBase::GetLogStatus() const { return xbFalse; } @@ -258,6 +310,7 @@ xbInt16 xbXBase::FlushLog() { void xbXBase::SetLogSize( size_t lSize ) { return; } + #endif // XB_LOGGING_SUPPORT /*************************************************************************/ @@ -554,8 +607,8 @@ xbInt16 xbXBase::GetFunctionInfo( const xbString &sExpLine, char &cReturnType, x \param lMillisecs Milliseconds to sleep. */ void xbXBase::xbSleep( xbInt32 lMillisecs ){ - #ifdef WIN32 - Sleep( lMillisecs ); + #ifdef WIN32 + Sleep( (xbUInt32) lMillisecs ); #else usleep( (xbInt64) lMillisecs * 1000 ); #endif @@ -703,6 +756,7 @@ xbInt16 xbXBase::OpenHighestVersion( const xbString &sTableName, const xbString iRc = XB_FILE_NOT_FOUND; throw iRc; } + unsigned char cFileTypeByte; if(( iRc = f.GetXbaseFileTypeByte( f.GetFqFileName(), cFileTypeByte )) != XB_NO_ERROR ){ iErrorStop = 120; |