home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWFiles / Include / FWFilPar.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  5.2 KB  |  149 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:        FWFilPar.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWFILPAR_H
  11. #define FWFILPAR_H
  12.  
  13. #ifndef FWSTRS_H
  14. #include "FWStrs.h"
  15. #endif
  16.  
  17. #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
  18. #include <Types.h>
  19. #endif
  20.  
  21. #if FW_LIB_EXPORT_PRAGMAS
  22. #pragma lib_export on
  23. #endif
  24.  
  25. //========================================================================================
  26. // Forward class declarations
  27. //========================================================================================
  28. class FW_CLASS_ATTR FW_CDirectorySpecification;
  29.  
  30.  
  31. //========================================================================================
  32. // Parsing Constants
  33. //========================================================================================
  34. const FW_Char FW_kExtensionDelimiter = (FW_Char)('.');
  35.     
  36. #ifdef FW_BUILD_WIN
  37. const FW_Char FW_kPathDelimiter = (FW_Char)('\\');
  38. const FW_Char FW_kDriveDelimiter = (FW_Char)(':');
  39. #endif
  40.  
  41. #ifdef FW_BUILD_MAC
  42. const FW_Char FW_kPathDelimiter = (FW_Char)(':');
  43. const FW_Char FW_kDriveDelimiter = (FW_Char)(':');
  44. #endif
  45.  
  46.  
  47. //========================================================================================
  48. // CLASS FW_CPrivFileSystemParser
  49. //
  50. // This class is a helper class for FW_CFileSpecification and FW_CDirectorySpecification.
  51. //   It provides methods to parse file names and extract different parts.
  52. //========================================================================================
  53.  
  54. class FW_CLASS_ATTR FW_CPrivFileSystemParser
  55. {
  56. public:
  57.     static FW_Boolean IsPartialPath(const FW_CString& pathName);
  58.         // Returns TRUE if pathName specifies a partial pathName.  This routine is
  59.         //   an implementation routine, but may be used by subclasses.
  60.  
  61.     static void AddDelimiter(FW_CString& pathName);
  62.         // Adds a trailing delimiter character to the pathName if one belongs
  63.         //   there.  
  64.  
  65.     static FW_Boolean HasExtension(const FW_CString& fileName,
  66.                                       FW_CharacterPosition& dotPosition);
  67.         // Returns TRUE if the fileName has a dot-extension.  Returns the position of
  68.         //   the dot as an index into fileName.
  69.  
  70.     static void ChangeExtension(const FW_CString& pathName,
  71.                                    const FW_CString& extension,
  72.                                    FW_CString& returnName);
  73.         // Changes the Windows file extension for the file specified by pathName.  
  74.         //   The new pathName is returned in returnName.  If no extension existed, then
  75.         //   the new extension is just added.
  76.  
  77.     static FW_Boolean GetExtension(const FW_CString& pathName,
  78.                                       FW_CString& extension);
  79.         // Gets the Windows file extension of the file specified by pathName and returns
  80.         //   it in extension.  Returns TRUE if there was an extension to return.
  81.  
  82.     static FW_Boolean GetFileName(const FW_CString& pathName,
  83.                                      FW_CString& fileName);
  84.         // Determines the file name and extension of pathName and returns it in fileName.
  85.         //   Returns TRUE if there was a filename to return, or FALSE if there was none.
  86.         //   Note that this doesn't throw exceptions because it can be used for directories
  87.         //   as well as files.
  88.  
  89.     static FW_Boolean GetJustFileName(const FW_CString& pathName,
  90.                                          FW_CString& fileName);
  91.         // Returns the file name without extension of pathName.  Returns TRUE if there
  92.         //   was a file name portion to return.
  93.  
  94.     static short PrivGetWorkingDirectory(FW_CString& pathName);
  95.         // Return the current working directory as a text string.
  96.  
  97. #ifdef FW_BUILD_WIN
  98. public:
  99.     static FW_Boolean WinGetPathName(const FW_CString& fullPathName,
  100.                                      FW_CString& pathName);
  101.         // Returns the path portion of fullPathName.  This works for both files and
  102.         //   directories.  Returns TRUE if there was a path portion to return.
  103.  
  104.     static FW_Boolean WinGetDrivePath(const FW_CString& pathName,
  105.                                       FW_CString& drivePath);
  106.         // Returns the drive letter and colon character portion of pathName.  Returns
  107.         //   TRUE if there was a drive letter to return.
  108.  
  109.     static void WinExpandPartialPath(FW_CString& pathName);
  110.         // Takes a partial pathName and expands it to a fully qualified path.
  111.         //   pathName contains the partial path on entry and the full path on exit.
  112.         //   Since the old contents of pathName get overwritten, the user may want
  113.         //   to store a copy of them somewhere.
  114.  
  115. #endif
  116.  
  117.  
  118. #ifdef FW_BUILD_MAC
  119. public:
  120.     static OSErr MacGenerateFullPathName(short vRefNum,
  121.                                               long dirID,
  122.                                               FW_CString& pathName);
  123.         // Generates a full Macintosh pathname based on vRefNum and dirID.  Returns
  124.         //   TRUE if the path was successfully generated, otherwise returns FALSE.
  125.  
  126.     static OSErr MacGenerateDirectory(short vRefNum,
  127.                                            long dirID,
  128.                                            FW_CDirectorySpecification& directory);
  129.         // Generates a directory spec based on vRefNum and dirID.  This routine can
  130.         //   be used recursively to generate a full directory pathname.
  131. #endif
  132.  
  133. private:
  134. #ifdef FW_BUILD_WIN16
  135.     static short PrivPrimitiveGetDefaultDrive();
  136.     static short PrivPrimitiveGetCurrentDir(FW_Char* namePtr);
  137. #endif
  138.  
  139.     FW_CPrivFileSystemParser() {}
  140.         // This is a package class.
  141.  
  142. };
  143.  
  144. #if FW_LIB_EXPORT_PRAGMAS
  145. #pragma lib_export off
  146. #endif
  147.  
  148. #endif
  149.