diff options
Diffstat (limited to 'src/core/xbssv.cpp')
-rwxr-xr-x | src/core/xbssv.cpp | 115 |
1 files changed, 100 insertions, 15 deletions
diff --git a/src/core/xbssv.cpp b/src/core/xbssv.cpp index d3e1070..532f942 100755 --- a/src/core/xbssv.cpp +++ b/src/core/xbssv.cpp @@ -21,6 +21,7 @@ const xbErrorMessage xbErrorMessages[] = { { XB_NO_ERROR, "No Error" }, { XB_NO_MEMORY, "No Memory" }, { XB_INVALID_OPTION, "Invalid Option" }, + { XB_INVALID_PARAMETER, "Invalid Parameter" }, { XB_DUP_TABLE_OR_ALIAS, "Duplicate Alias/Table Name" }, { XB_INVALID_NODELINK, "Invalid Node Link" }, { XB_KEY_NOT_UNIQUE, "Key Not Unique" }, @@ -77,7 +78,6 @@ const xbErrorMessage xbErrorMessages[] = { }; // see also xbretcod.h - xbInt16 xbSsv::iEndianType = 0; xbString xbSsv::sDefaultDateFormat = "MM/DD/YY"; @@ -85,17 +85,12 @@ xbInt16 xbSsv::iDefaultFileVersion = 4; xbString xbSsv::sNullString = ""; xbBool xbSsv::bDefaultAutoCommit = xbTrue; - -#ifdef WIN32 -xbString xbSsv::sDataDirectory = PROJECT_DATA_DIR; -#else -xbString xbSsv::sDataDirectory = PROJECT_DATA_DIR; -#endif // +xbString xbSsv::sDataDirectory = PROJECT_DATA_DIR; +xbString xbSsv::sTempDirectory = PROJECT_TEMP_DIR; #ifdef XB_LOGGING_SUPPORT -xbString xbSsv::sLogDirectory = PROJECT_LOG_DIR; -//xbString xbSsv::sLogDirectory = ""; -xbString xbSsv::sLogFileName = PROJECT_DFLT_LOGFILE; +xbString xbSsv::sLogDirectory = PROJECT_LOG_DIR; +xbString xbSsv::sLogFileName = PROJECT_DFLT_LOGFILE; #endif // XB_LOGGING_SUPPORT #ifdef XB_LOCKING_SUPPORT @@ -223,25 +218,51 @@ const char * xbSsv::GetErrorMessage( xbInt16 iErrorCode ) const{ //! @brief Get home directory. /*! \param sHomeDirOut - Output home directory for current user. - \returns void */ void xbSsv::GetHomeDir( xbString &sHomeDirOut ){ - #ifdef WIN32 + #ifdef HAVE_GETENV_S_F + + char sPath[MAX_PATH]; + size_t lSize; + + sHomeDirOut = ""; + memset( sPath, 0x00, MAX_PATH ); + + getenv_s( &lSize, NULL, 0, "HOMEDRIVE" ); + if( lSize > 0 ){ + getenv_s( &lSize, sPath, lSize, "HOMEDRIVE" ); + sHomeDirOut = sPath; + memset( sPath, 0x00, MAX_PATH ); + } + + getenv_s( &lSize, NULL, 0, "HOMEPATH" ); + if( lSize > 0 ){ + getenv_s( &lSize, sPath, lSize, "HOMEPATH" ); + sHomeDirOut += sPath; + } + if( sHomeDirOut == "" ) + sHomeDirOut = "C:\xbase64"; + + #elif defined(WIN32) sHomeDirOut.Sprintf( "%s%s", getenv( "HOMEDRIVE" ), getenv( "HOMEPATH" )); + #else sHomeDirOut.Sprintf( "%s", getenv( "HOME" )); sHomeDirOut.Trim(); if( sHomeDirOut == "" ) sHomeDirOut.Sprintf( "%s", getpwuid( getuid())->pw_dir ); #endif + sHomeDirOut.Trim(); } + + /*************************************************************************/ //! @brief Set the data directory. /*! - \param sDataDirectory Set the data direcroty. + \param sDataDirectory Set the data directory. */ void xbSsv::SetDataDirectory( const xbString &sDataDirectory ){ @@ -302,12 +323,55 @@ void xbSsv::SetEndianType() { } /*************************************************************************/ +//! @brief Set the temp directory. +/*! + \param sTempDirectory Set the data direcroty. +*/ + +void xbSsv::SetTempDirectory( const xbString &sTempDirectory ){ + this->sTempDirectory = sTempDirectory; + + #ifdef WIN32 + this->sTempDirectory.SwapChars( '/', '\\' ); + #else + this->sTempDirectory.SwapChars( '\\', '/' ); + #endif + +} + +/*************************************************************************/ +//! @brief Get the OS dependent path separator. +/*! + \returns Returns '\' for windows environment, otherwise returns '/'. +*/ + +char xbSsv::GetPathSeparator() const { + #ifdef WIN32 + return '\\'; + #else + return '/'; + #endif +} + +/*************************************************************************/ +//! @brief Get the current temp directory. +/*! + \returns xbString containing the current data directory + where the database files are stored. +*/ + +xbString &xbSsv::GetTempDirectory() const { + return sTempDirectory; +} + +/*************************************************************************/ #ifdef XB_LOGGING_SUPPORT //! @brief Get the default log file name. /*! \returns Returns the log file name. */ + xbString & xbSsv::GetLogFileName() const { return sLogFileName; } @@ -317,17 +381,18 @@ xbString & xbSsv::GetLogFileName() const { /*! \returns Returns the log directory. */ + + xbString & xbSsv::GetLogDirectory() const { return sLogDirectory; } - - /*************************************************************************/ //! @brief Set the default log directory name. /*! \param sLogDirectory Name of desired log directory. */ + void xbSsv::SetLogDirectory( const xbString &sLogDirectoryIn ){ this->sLogDirectory = sLogDirectoryIn; @@ -339,13 +404,29 @@ void xbSsv::SetLogDirectory( const xbString &sLogDirectoryIn ){ } +//! @brief Set the log file name. +/*! + \param sLogFileName - Log File Name. + \return void +*/ + +void xbSsv::SetLogFileName( const xbString & sLogFileName ){ + + this->sLogFileName = sLogFileName; +} + + #else xbString & xbSsv::GetLogFileName() const { return sNullString; } + xbString & xbSsv::GetLogDirectory() const { + +std::cout << "xbSsv::GetLogDirectory() returning null\n"; + return sNullString; } @@ -353,6 +434,10 @@ void xbSsv::SetLogDirectory( const xbString &sLogDirectory ){ return; } +void xbSsv::SetLogFileName( const xbString & sLogFileName ){ + return; +} + #endif /*************************************************************************/ |