home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 5.2 KB | 149 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFilPar.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWFILPAR_H
- #define FWFILPAR_H
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
- #include <Types.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
- class FW_CLASS_ATTR FW_CDirectorySpecification;
-
-
- //========================================================================================
- // Parsing Constants
- //========================================================================================
- const FW_Char FW_kExtensionDelimiter = (FW_Char)('.');
-
- #ifdef FW_BUILD_WIN
- const FW_Char FW_kPathDelimiter = (FW_Char)('\\');
- const FW_Char FW_kDriveDelimiter = (FW_Char)(':');
- #endif
-
- #ifdef FW_BUILD_MAC
- const FW_Char FW_kPathDelimiter = (FW_Char)(':');
- const FW_Char FW_kDriveDelimiter = (FW_Char)(':');
- #endif
-
-
- //========================================================================================
- // CLASS FW_CPrivFileSystemParser
- //
- // This class is a helper class for FW_CFileSpecification and FW_CDirectorySpecification.
- // It provides methods to parse file names and extract different parts.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPrivFileSystemParser
- {
- public:
- static FW_Boolean IsPartialPath(const FW_CString& pathName);
- // Returns TRUE if pathName specifies a partial pathName. This routine is
- // an implementation routine, but may be used by subclasses.
-
- static void AddDelimiter(FW_CString& pathName);
- // Adds a trailing delimiter character to the pathName if one belongs
- // there.
-
- static FW_Boolean HasExtension(const FW_CString& fileName,
- FW_CharacterPosition& dotPosition);
- // Returns TRUE if the fileName has a dot-extension. Returns the position of
- // the dot as an index into fileName.
-
- static void ChangeExtension(const FW_CString& pathName,
- const FW_CString& extension,
- FW_CString& returnName);
- // Changes the Windows file extension for the file specified by pathName.
- // The new pathName is returned in returnName. If no extension existed, then
- // the new extension is just added.
-
- static FW_Boolean GetExtension(const FW_CString& pathName,
- FW_CString& extension);
- // Gets the Windows file extension of the file specified by pathName and returns
- // it in extension. Returns TRUE if there was an extension to return.
-
- static FW_Boolean GetFileName(const FW_CString& pathName,
- FW_CString& fileName);
- // Determines the file name and extension of pathName and returns it in fileName.
- // Returns TRUE if there was a filename to return, or FALSE if there was none.
- // Note that this doesn't throw exceptions because it can be used for directories
- // as well as files.
-
- static FW_Boolean GetJustFileName(const FW_CString& pathName,
- FW_CString& fileName);
- // Returns the file name without extension of pathName. Returns TRUE if there
- // was a file name portion to return.
-
- static short PrivGetWorkingDirectory(FW_CString& pathName);
- // Return the current working directory as a text string.
-
- #ifdef FW_BUILD_WIN
- public:
- static FW_Boolean WinGetPathName(const FW_CString& fullPathName,
- FW_CString& pathName);
- // Returns the path portion of fullPathName. This works for both files and
- // directories. Returns TRUE if there was a path portion to return.
-
- static FW_Boolean WinGetDrivePath(const FW_CString& pathName,
- FW_CString& drivePath);
- // Returns the drive letter and colon character portion of pathName. Returns
- // TRUE if there was a drive letter to return.
-
- static void WinExpandPartialPath(FW_CString& pathName);
- // Takes a partial pathName and expands it to a fully qualified path.
- // pathName contains the partial path on entry and the full path on exit.
- // Since the old contents of pathName get overwritten, the user may want
- // to store a copy of them somewhere.
-
- #endif
-
-
- #ifdef FW_BUILD_MAC
- public:
- static OSErr MacGenerateFullPathName(short vRefNum,
- long dirID,
- FW_CString& pathName);
- // Generates a full Macintosh pathname based on vRefNum and dirID. Returns
- // TRUE if the path was successfully generated, otherwise returns FALSE.
-
- static OSErr MacGenerateDirectory(short vRefNum,
- long dirID,
- FW_CDirectorySpecification& directory);
- // Generates a directory spec based on vRefNum and dirID. This routine can
- // be used recursively to generate a full directory pathname.
- #endif
-
- private:
- #ifdef FW_BUILD_WIN16
- static short PrivPrimitiveGetDefaultDrive();
- static short PrivPrimitiveGetCurrentDir(FW_Char* namePtr);
- #endif
-
- FW_CPrivFileSystemParser() {}
- // This is a package class.
-
- };
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-