diff --git a/flaim/src/ffilesys.cpp b/flaim/src/ffilesys.cpp index 4d5acef..85feab7 100644 --- a/flaim/src/ffilesys.cpp +++ b/flaim/src/ffilesys.cpp @@ -1058,6 +1058,80 @@ Exit: #endif } +/**************************************************************************** +Desc: Set the Read-Only Attribute (not supported on all platforms). +****************************************************************************/ +RCODE F_FileSystemImp::SetReadOnly( + const char * pszFileName, + FLMBOOL bReadOnly) +{ + RCODE rc = FERR_OK; + +#if defined( FLM_UNIX) + struct stat filestatus; + + if( stat( (char *)pszFileName, &filestatus)) + { + flmAssert( 0); + rc = RC_SET( FERR_FAILURE); + goto Exit; + } + + if ( bReadOnly) + { + filestatus.st_mode &= ~S_IWUSR; + } + else + { + filestatus.st_mode |= S_IWUSR; + } + + if ( chmod( (char *)pszFileName, filestatus.st_mode)) + { + rc = RC_SET( FERR_FAILURE); + goto Exit; + } + +#elif defined( FLM_WIN) + + DWORD dwAttr; + + dwAttr = GetFileAttributes( (LPTSTR)pszFileName); + if( dwAttr == (DWORD)-1) + { + rc = RC_SET( FERR_IO_PATH_NOT_FOUND); + goto Exit; + } + + if ( bReadOnly) + { + dwAttr |= XF_IO_FA_RDONLY; + } + else + { + dwAttr &= ~XF_IO_FA_RDONLY; + } + + if( !SetFileAttributes( (LPTSTR)pszFileName, dwAttr)) + { + rc = RC_SET_AND_ASSERT( FERR_FAILURE); + goto Exit; + } +#elif defined( FLM_NLM) + + if ( RC_BAD( rc = flmNetWareSetReadOnly( pszFileName, bReadOnly))) + { + goto Exit; + } +#else + rc = RC_SET_AND_ASSERT( FERR_NOT_IMPLEMENTED); +#endif + +Exit: + + return( rc); +} + /**************************************************************************** Desc: stat tpath to see if it is a directory ****************************************************************************/ diff --git a/flaim/src/ffilesys.h b/flaim/src/ffilesys.h index ce17637..ab428fb 100644 --- a/flaim/src/ffilesys.h +++ b/flaim/src/ffilesys.h @@ -115,6 +115,10 @@ public: // Miscellaneous methos + RCODE SetReadOnly( + const char * pszFileName, + FLMBOOL bReadOnly); + RCODE GetSectorSize( // Get the sector size of the volume for const char * pFileName, // this file. FLMUINT * puiSectorSize); diff --git a/flaim/src/flaim.h b/flaim/src/flaim.h index 3178b0d..7d3509f 100644 --- a/flaim/src/flaim.h +++ b/flaim/src/flaim.h @@ -2814,6 +2814,8 @@ ///< function whenever it is called. } eDbConfigType; +#define F_SERIAL_NUM_SIZE 16 + /// Options for FlmDbGetConfig(). typedef enum { @@ -6478,6 +6480,15 @@ const char * pszDestFilePath, // Name of destination file. FLMBOOL bOverwrite, // Overwrite destination file? FLMUINT * puiBytesCopied) = 0; // Number of bytes copied. + + virtual RCODE SetReadOnly( + const char * pszFileName, + FLMBOOL bReadOnly) = 0; + + virtual RCODE GetSectorSize( // Get the sector size of the volume for + const char * pFileName, // this file. + FLMUINT * puiSectorSize) = 0; + }; RCODE FlmAllocFileSystem( diff --git a/flaim/src/fsysdata.cpp b/flaim/src/fsysdata.cpp index cbbdbf8..2c83bb4 100644 --- a/flaim/src/fsysdata.cpp +++ b/flaim/src/fsysdata.cpp @@ -5191,6 +5191,27 @@ Exit: return( rc); } +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FlmAllocDirHdl( + F_DirHdl ** ppDirHdl) +{ + RCODE rc = FERR_OK; + + flmAssert( ppDirHdl && *ppDirHdl == NULL); + + if( (*ppDirHdl = f_new F_DirHdlImp) == NULL) + { + rc = RC_SET( FERR_MEM); + goto Exit; + } + +Exit: + + return( rc); +} + /**************************************************************************** Desc: ****************************************************************************/ diff --git a/flaim/src/ftk.h b/flaim/src/ftk.h index 36bbfb4..6ad171c 100644 --- a/flaim/src/ftk.h +++ b/flaim/src/ftk.h @@ -1607,15 +1607,43 @@ void intToByte( File Path Functions & Macros ****************************************************************************/ -// This defines the maximum file size we can support for ANY -// platform, ANY file type. It is not 4Gb because of a bug in direct IO -// on Netware. The limitation is that in direct IO mode (on the legacy file -// system) we are not allowed room for the last block. If the block -// size were 64K for example, direct IO only lets us expand to a size of -// 0xFFFF0000. Since we can't anticipate what the block size will be, -// we have to set a maximum that accounts for the maximum block size we -// may ever see. At this point, we are assuming it won't ever be more -// than 256K on legacy file systems. Thus, our limit of 0xFFFC0000. +#if defined( FLM_WIN) || defined( FLM_NLM) + #define FWSLASH '/' + #define SLASH '\\' + #define SSLASH "\\" + #define COLON ':' + #define PERIOD '.' + #define PARENT_DIR ".." + #define CURRENT_DIR "." +#else + #ifndef FWSLASH + #define FWSLASH '/' + #endif + + #ifndef SLASH + #define SLASH '/' + #endif + + #ifndef SSLASH + #define SSLASH "/" + #endif + + #ifndef COLON + #define COLON ':' + #endif + + #ifndef PERIOD + #define PERIOD '.' + #endif + + #ifndef PARENT_DIR + #define PARENT_DIR ".." + #endif + + #ifndef CURRENT_DIR + #define CURRENT_DIR "." + #endif +#endif /**************************************************************************** CPU Release Functions @@ -1803,8 +1831,6 @@ FLMUINT32 ftkAtomicExchange( Pseudo Serial Numbers ****************************************************************************/ -#define F_SERIAL_NUM_SIZE 16 - RCODE f_initSerialNumberGenerator( void); RCODE f_createSerialNumber(