From dd70ff8bf32c2d7ed365004b1770058265db1978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 11 Mar 2023 18:15:37 +0100 Subject: New upstream version 4.1.0 --- src/core/xbssv.cpp | 111 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 43 deletions(-) (limited to 'src/core/xbssv.cpp') diff --git a/src/core/xbssv.cpp b/src/core/xbssv.cpp index 252daab..d3e1070 100755 --- a/src/core/xbssv.cpp +++ b/src/core/xbssv.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. @@ -15,8 +15,6 @@ Email Contact: #include "xbase.h" - - namespace xb{ const xbErrorMessage xbErrorMessages[] = { @@ -26,6 +24,7 @@ const xbErrorMessage xbErrorMessages[] = { { XB_DUP_TABLE_OR_ALIAS, "Duplicate Alias/Table Name" }, { XB_INVALID_NODELINK, "Invalid Node Link" }, { XB_KEY_NOT_UNIQUE, "Key Not Unique" }, + { XB_MEMCPY_ERROR, "Memory copy failure" }, { XB_FILE_EXISTS, "File Already Exists" }, { XB_ALREADY_OPEN, "Database already open" }, { XB_DBF_FILE_NOT_OPEN, "DBF File Not Open" }, @@ -49,6 +48,8 @@ const xbErrorMessage xbErrorMessages[] = { { XB_INVALID_TABLE_NAME, "Invalid Table Name" }, { XB_EMPTY, "Empty Table or Index" }, { XB_LIMIT_REACHED, "Limit Reached" }, + { XB_BLOCKREAD_NOT_ENABLED, "Block Read Mode is not enabled" }, + { XB_DIRECTORY_ERROR, "Directory Read/Write error" }, { XB_INVALID_FIELD_TYPE, "Unknown Field Type" }, { XB_INVALID_FIELD_NO, "Invalid Field Number" }, { XB_INVALID_DATA, "Invalid Data" }, @@ -89,12 +90,13 @@ xbBool xbSsv::bDefaultAutoCommit = xbTrue; xbString xbSsv::sDataDirectory = PROJECT_DATA_DIR; #else xbString xbSsv::sDataDirectory = PROJECT_DATA_DIR; -#endif +#endif // #ifdef XB_LOGGING_SUPPORT -xbString xbSsv::sDefaultLogDirectory = PROJECT_LOG_DIR; -xbString xbSsv::sDefaultLogFileName = PROJECT_DFLT_LOGFILE; -#endif +xbString xbSsv::sLogDirectory = PROJECT_LOG_DIR; +//xbString xbSsv::sLogDirectory = ""; +xbString xbSsv::sLogFileName = PROJECT_DFLT_LOGFILE; +#endif // XB_LOGGING_SUPPORT #ifdef XB_LOCKING_SUPPORT xbInt32 xbSsv::lDefaultLockWait = 100; @@ -104,18 +106,21 @@ xbInt16 xbSsv::iDefaultLockFlavor = 1; xbBool xbSsv::bMultiUser = xbTrue; #else xbBool xbSsv::bMultiUser = xbFalse; -#endif +#endif // XB_LOCKING_SUPPORT #if defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT) xbInt16 xbSsv::iUniqueKeyOpt = XB_HALT_ON_DUPKEY; // is one of XB_HALT_ON_DUPKEY || XB_EMULATE_DBASE -#endif +#endif // defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT) #ifdef XB_MDX_SUPPORT xbInt16 xbSsv::iCreateMdxBlockSize = 1024; // 1024 is DBase 7 default size for MDX index blocks -#endif +#endif // XB_MDX_SUPPORT +#ifdef XB_BLOCKREAD_SUPPORT +xbUInt32 xbSsv::ulDefaultBlockReadSize = 32768; // 32K buffer for block DBF datafile reads +#endif // XB_BLOCKREAD_SUPPORT /*************************************************************************/ //! @brief Class Constructor. @@ -139,7 +144,6 @@ void xbSsv::BitDump( char c ) const { xbBool xbSsv::BitSet( unsigned char c, xbInt16 iBitNo ) const { return c & 1 << iBitNo; } - /*************************************************************************/ //! @brief Display error message on console for a given error number. /*! @@ -164,7 +168,6 @@ void xbSsv::DisplayError( xbInt16 iErrorCode ) const { xbBool xbSsv::GetDefaultAutoCommit() const { return bDefaultAutoCommit; } - /*************************************************************************/ //! @brief Get the current data directory. /*! @@ -184,19 +187,6 @@ xbString &xbSsv::GetDataDirectory() const { xbString & xbSsv::GetDefaultDateFormat() const { return sDefaultDateFormat; } - -/*************************************************************************/ -// @brief Get the default file format version. -/* - \returns 3 - Dbase III file format
- 4 - Dbase IV file format
-*/ - -/* -xbInt16 xbSsv::GetDefaultFileVersion() const { - return iDefaultFileVersion; -} -*/ /*************************************************************************/ //! @brief Get the Endian type. /*! @@ -206,7 +196,6 @@ xbInt16 xbSsv::GetDefaultFileVersion() const { xbInt16 xbSsv::GetEndianType() const { return iEndianType; } - /*************************************************************************/ //! @brief Get an error message. /*! @@ -230,7 +219,25 @@ const char * xbSsv::GetErrorMessage( xbInt16 iErrorCode ) const{ } return ""; } +/*************************************************************************/ +//! @brief Get home directory. +/*! + \param sHomeDirOut - Output home directory for current user. + \returns void +*/ + +void xbSsv::GetHomeDir( xbString &sHomeDirOut ){ + #ifdef 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. /*! @@ -240,7 +247,6 @@ const char * xbSsv::GetErrorMessage( xbInt16 iErrorCode ) const{ void xbSsv::SetDataDirectory( const xbString &sDataDirectory ){ this->sDataDirectory = sDataDirectory; - #ifdef WIN32 this->sDataDirectory.SwapChars( '/', '\\' ); #else @@ -302,57 +308,53 @@ void xbSsv::SetEndianType() { /*! \returns Returns the log file name. */ -xbString & xbSsv::GetDefaultLogFileName() const { - return sDefaultLogFileName; +xbString & xbSsv::GetLogFileName() const { + return sLogFileName; } - /*************************************************************************/ //! @brief Get the default log directory. /*! \returns Returns the log directory. */ -xbString & xbSsv::GetDefaultLogDirectory() const { - return sDefaultLogDirectory; +xbString & xbSsv::GetLogDirectory() const { + return sLogDirectory; } /*************************************************************************/ //! @brief Set the default log directory name. /*! - \param sDefaultLogDirectory Name of desired log directory. + \param sLogDirectory Name of desired log directory. */ -void xbSsv::SetDefaultLogDirectory( const xbString &sDefaultLogDirectory ){ - - this->sDefaultLogDirectory = sDefaultLogDirectory; +void xbSsv::SetLogDirectory( const xbString &sLogDirectoryIn ){ + this->sLogDirectory = sLogDirectoryIn; #ifdef WIN32 - this->sDefaultLogDirectory.SwapChars( '/', '\\' ); + this->sLogDirectory.SwapChars( '/', '\\' ); #else - this->sDefaultLogDirectory.SwapChars( '\\', '/' ); + this->sLogDirectory.SwapChars( '\\', '/' ); #endif - } #else -xbString & xbSsv::GetDefaultLogFileName() const { +xbString & xbSsv::GetLogFileName() const { return sNullString; } -xbString & xbSsv::GetDefaultLogDirectory() const { +xbString & xbSsv::GetLogDirectory() const { return sNullString; } -void xbSsv::SetDefaultLogDirectory( const xbString &sDefaultLogDirectory ){ +void xbSsv::SetLogDirectory( const xbString &sLogDirectory ){ return; } #endif - /*************************************************************************/ #ifdef XB_LOCKING_SUPPORT @@ -541,6 +543,29 @@ xbInt16 xbSsv::SetUniqueKeyOpt( xbInt16 iOpt ){ } #endif /************************************************************************/ +#ifdef XB_BLOCKREAD_SUPPORT + +//! @brief Get Default Read Block Size +/*! + This routine returns the default read block size used when allocating + buffer space for block reads of table data. Initial setting is 32768 bytes. +*/ +xbUInt32 xbSsv::GetDefaultBlockReadSize() const { + return ulDefaultBlockReadSize; +} + + +//! @brief Set Default Read Block Size +/*! + This routine sets the default read block size used when allocating + buffer space for block reads of table data. Initial setting is 32768 bytes. +*/ +void xbSsv::SetDefaultBlockReadSize( xbUInt32 ulDfltBlockReadSize ){ + ulDefaultBlockReadSize = ulDfltBlockReadSize; +} + +#endif // XB_BLOCKREAD_SUPPORT +/************************************************************************/ -- cgit v1.2.3