home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.9 KB | 352 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: SLFileSy.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef SLFILESY_H
- #define SLFILESY_H
-
- #if defined(FW_BUILD_MAC) && !defined(__FILES__)
- #include "Files.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__ERRORS__)
- #include "Errors.h"
- #endif
-
- #ifndef SLSTRREP_H
- #include "SLStrRep.h"
- #endif
-
- #ifdef FW_BUILD_WIN16
- // WINVER 0x30a
- #include <windows.h>
- #endif
-
- #ifdef FW_BUILD_WIN32
- #include <winerror.h>
- #include <winbase.h>
- #endif
-
- // Export or Import functions for CFM-68K [sfu]
-
- #if defined(FW_ODFLIB_IMPORT)
- #pragma import on
- #elif defined(FW_ODFLIB)
- #pragma export on
- #endif
-
- FW_EXTERN_C_BEGIN
-
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
- class FW_OFileSpecification;
- class FW_ODirectorySpecification;
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- #ifdef FW_BUILD_WIN16
- typedef HFILE FW_PlatformFileHandle;
- #endif
-
- #ifdef FW_BUILD_WIN32
- typedef HANDLE FW_PlatformFileHandle;
- #endif
-
- #ifdef FW_BUILD_MAC
- typedef short FW_PlatformFileHandle;
- const OSType FW_kDefaultFileType = 'TEXT';
- const OSType FW_kDefaultCreatorType = 'ttxt';
- #endif
-
- const FW_PlatformFileHandle FW_kInvalidAccessHandle = (FW_PlatformFileHandle)(-1);
- const long FW_kInvalidSeek = -1;
-
-
- //========================================================================================
- // FW_EAccess and FW_EDeny
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- enum FW_EAccess
- {
- FW_kRead = fsRdPerm,
- FW_kWrite = fsWrPerm,
- FW_kReadWrite = fsRdWrPerm
- };
-
- // Mac defines these constants as bit positions.
- enum FW_EDeny
- {
- FW_kDenyNone = 0x00,
- FW_kDenyRead = 0x10,
- FW_kDenyWrite = 0x20,
- FW_kDenyReadWrite = 0x30
- };
- #endif
-
-
- #ifdef FW_BUILD_WIN16
- enum FW_EAccess
- {
- FW_kRead = OF_READ,
- FW_kWrite = OF_WRITE,
- FW_kReadWrite = OF_READWRITE
- };
-
-
- enum FW_EDeny
- {
- FW_kDenyNone = OF_SHARE_DENY_NONE,
- FW_kDenyRead = OF_SHARE_DENY_READ,
- FW_kDenyWrite = OF_SHARE_DENY_WRITE,
- FW_kDenyReadWrite = OF_SHARE_EXCLUSIVE
- };
- #endif
-
-
- #ifdef FW_BUILD_WIN32
- enum FW_EAccess
- {
- FW_kRead = GENERIC_READ,
- FW_kWrite = GENERIC_WRITE,
- FW_kReadWrite = GENERIC_READ | GENERIC_WRITE
- };
-
-
- enum FW_EDeny
- {
- FW_kDenyNone = FILE_SHARE_READ | FILE_SHARE_WRITE,
- FW_kDenyRead = FILE_SHARE_WRITE,
- FW_kDenyWrite = FILE_SHARE_READ,
- FW_kDenyReadWrite = 0
- };
- #endif
-
-
- //========================================================================================
- // FW_SAccessPermission
- //
- // "C" class defining the structure of access permissions
- //========================================================================================
-
- struct FW_SAccessPermission
- {
- unsigned long fAccess;
- unsigned long fDeny;
- };
-
- //========================================================================================
- // FW_PrivFileSystem
- //
- // Common file operations, private version. The error values, if any, are returned via
- // the Environment variable.
- //========================================================================================
-
- void SL_API
- FW_PrivFileSystem_CreateFile(Environment* ev, FW_OFileSpecification* fileSpec, FW_Boolean overWriteExisting = FALSE);
- // Creates the file specified by fileSpec. If the file already exists and
- // overWriteExisting is TRUE, then the file will be truncated to zero-length.
- // Otherwise, the file will be left alone.
-
- void SL_API
- FW_PrivFileSystem_DeleteFile(Environment* ev, FW_OFileSpecification* fileSpec);
- // Deletes the file specified by fileSpec. WARNING: This action cannot be undone.
-
- void SL_API
- FW_PrivFileSystem_CreateDirectory(Environment* ev, FW_ODirectorySpecification* directory);
- // Creates the directory specified by directory. If the directory already
- // exists, then nothing is done.
-
- void SL_API
- FW_PrivFileSystem_DeleteDirectory(Environment* ev, FW_ODirectorySpecification* directory);
- // Deletes the directory specified by directory. This routine will only
- // delete an empty directory. The user must make sure that there are no
- // files left in the directory. The directory must also not be the current
- // working directory for it to be deleted. Use SetCurrentDirectory to set
- // another directory if this is the case.
-
- void SL_API
- FW_PrivFileSystem_GetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory);
- // Sets directory to point to the current default directory.
-
- void SL_API
- FW_PrivFileSystem_SetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory);
- // Set the current working directory.
-
- FW_Boolean SL_API
- FW_PrivFileSystem_IsValidDirectory(Environment* ev, FW_ODirectorySpecification* directory);
- // Returns TRUE if the specified directory exists.
-
- FW_Boolean SL_API
- FW_PrivFileSystem_IsValidDrive(Environment* ev, FW_HString driveName);
- // Returns TRUE if the specified drive exists.
-
- FW_Boolean SL_API
- FW_PrivFileSystem_IsValidFile(Environment* ev, FW_OFileSpecification* theFile);
- // Tests the existence of a file.
-
- #ifdef FW_BUILD_WIN
- FW_Boolean SL_API
- FW_PrivFileSystem_WinPathExists(Environment* ev, FW_HString pathName);
- // Tests the existence of a particular path and/or filename. Paths should NOT
- // be terminated with a path delimiter.
- #endif
-
- #ifdef FW_BUILD_MAC
- FW_Boolean SL_API
- FW_PrivFileSystem_MacIsVolumeShared(Environment* ev, short volumeRefNum);
- // Returns TRUE if the volume specified by volumeRefNum
- #endif
-
-
- //========================================================================================
- // FW_FileSystem
- //
- // Common file operations, public version. These routines call the private versions and
- // throw on error.
- //========================================================================================
-
- inline void
- FW_FileSystem_CreateFile(Environment* ev, FW_OFileSpecification* fileSpec, FW_Boolean overWriteExisting = FALSE)
- {
- FW_PrivFileSystem_CreateFile(ev, fileSpec, overWriteExisting);
- FW_FailOnEvError(ev);
- }
-
- inline void
- FW_FileSystem_DeleteFile(Environment* ev, FW_OFileSpecification* fileSpec)
- {
- FW_PrivFileSystem_DeleteFile(ev, fileSpec);
- FW_FailOnEvError(ev);
- }
-
- inline void
- FW_FileSystem_CreateDirectory(Environment* ev, FW_ODirectorySpecification* directory)
- {
- FW_PrivFileSystem_CreateDirectory(ev, directory);
- FW_FailOnEvError(ev);
- }
-
- inline void
- FW_FileSystem_DeleteDirectory(Environment* ev, FW_ODirectorySpecification* directory)
- {
- FW_PrivFileSystem_DeleteDirectory(ev, directory);
- FW_FailOnEvError(ev);
- }
-
- inline void
- FW_FileSystem_GetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory)
- {
- FW_PrivFileSystem_GetCurrentDirectory(ev, directory);
- FW_FailOnEvError(ev);
- }
-
- inline void
- FW_FileSystem_SetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory)
- {
- FW_PrivFileSystem_SetCurrentDirectory(ev, directory);
- FW_FailOnEvError(ev);
- }
-
- inline FW_Boolean
- FW_FileSystem_IsValidDirectory(Environment* ev, FW_ODirectorySpecification* directory)
- {
-
- FW_Boolean result = FW_PrivFileSystem_IsValidDirectory(ev, directory);
- FW_FailOnEvError(ev);
- return result;
- }
-
- inline FW_Boolean
- FW_FileSystem_IsValidDrive(Environment* ev, FW_HString driveName)
- {
-
- FW_Boolean result = FW_PrivFileSystem_IsValidDrive(ev, driveName);
- FW_FailOnEvError(ev);
- return result;
- }
-
- inline FW_Boolean
- FW_FileSystem_IsValidFile(Environment* ev, FW_OFileSpecification* theFile)
- {
-
- FW_Boolean result = FW_PrivFileSystem_IsValidFile(ev, theFile);
- FW_FailOnEvError(ev);
- return result;
- }
-
- #ifdef FW_BUILD_WIN
- inline FW_Boolean
- FW_FileSystem_WinPathExists(Environment* ev, FW_HString pathName)
- {
- FW_Boolean result = FW_PrivFileSystem_WinPathExists(ev, pathName);
- FW_FailOnEvError(ev);
- return result;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- inline FW_Boolean
- FW_FileSystem_MacIsVolumeShared(Environment* ev, short volumeRefNum)
- {
-
- FW_Boolean result = FW_PrivFileSystem_MacIsVolumeShared(ev, volumeRefNum);
- FW_FailOnEvError(ev);
- return result;
- }
- #endif
-
-
-
-
- #ifdef FW_BUILD_WIN16
- enum FW_EFS_MoveMethods
- {
- FW_kFromStart = 0,
- FW_kFromCurrent = 1,
- FW_kFromEnd = 2
- };
- #endif
-
- #ifdef FW_BUILD_WIN32
- enum FW_EFS_MoveMethods
- {
- FW_kFromStart = FILE_BEGIN,
- FW_kFromCurrent = FILE_CURRENT,
- FW_kFromEnd = FILE_END
- };
- #endif
-
-
- #ifdef FW_BUILD_MAC
- enum FW_EFS_MoveMethods
- {
- FW_kFromStart = fsFromStart,
- FW_kFromCurrent = fsFromMark,
- FW_kFromEnd = fsFromLEOF
- };
- #endif
-
- FW_EXTERN_C_END
-
- // For CFM-68K [sfu]
-
- #if defined(FW_ODFLIB_IMPORT)
- #pragma import off
- #elif defined(FW_ODFLIB)
- #pragma export off
- #endif
-
- #endif
-
-
-