home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 0 Macintosh 29Sep94 / DirStuff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  3.6 KB  |  102 lines  |  [TEXT/KAHL]

  1. /* DirStuff.h */
  2.  
  3. #ifndef Included_DirStuff_h
  4. #define Included_DirStuff_h
  5.  
  6. /* DirStuff module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12. /* Files */
  13.  
  14. /* Implementation Note:  This library depends on FileSpec == FSSpec.  If Files */
  15. /* decides to change this, then it must be changed here as well. */
  16. struct FileSpec;
  17.  
  18. /* directory data structure abstraction */
  19. struct DirectoryRec;
  20. typedef struct DirectoryRec DirectoryRec;
  21.  
  22. /* types of items that can be in a directory */
  23. typedef enum {eFile EXECUTE(= -2415), eSymbolicLink, eDirectory, eOther} DirFileTypes;
  24.  
  25. /* read the first level list of items in the specified directory.  NIL specifies */
  26. /* a root directory.  If NIL is returned, then the operation could not be completed */
  27. DirectoryRec*            ReadDirectory(struct FileSpec* Directory);
  28.  
  29. /* get rid of the directory structure when we are done with it */
  30. void                            DisposeDirectory(DirectoryRec* Dir);
  31.  
  32. /* find out how many entries there are in the directory structure */
  33. long                            GetDirectorySize(DirectoryRec* Dir);
  34.  
  35. /* return the item type of an indexed directory entry (indices start from 0) */
  36. /* Indices start from 0 up to GetDirectorySize() - 1 */
  37. DirFileTypes            GetDirectoryEntryType(DirectoryRec* Dir, long Index);
  38.  
  39. /* return a pointer containing the name of the specified directory entry or NIL */
  40. /* if allocation failed.  Name is not null terminated. */
  41. char*                            GetDirectoryEntryName(DirectoryRec* Dir, long Index);
  42.  
  43. /* get a file spec describing a directory entry */
  44. /* this entry is a standard FileSpec, the same type as used in the Files module */
  45. /* and should be manipulated and disposed using routines from Files */
  46. struct FileSpec*    GetDirectoryEntryFileSpec(DirectoryRec* Dir, long Index);
  47.  
  48. /* resort the directory alphabetically.  Returns True if it succeeded or */
  49. /* False if it failed. */
  50. MyBoolean                    ResortDirectory(DirectoryRec* Dir);
  51.  
  52. /* this compares to file specifications and returns True if they refer to the */
  53. /* same file */
  54. MyBoolean                    CompareFileSpecs(struct FileSpec* First, struct FileSpec* Second);
  55.  
  56. /* dereference a symbolic link one level only */
  57. struct FileSpec*    DereferenceSymbolicLink(struct FileSpec* Source);
  58.  
  59. /* get root file specification.  On UNIX, this would return "/"; on Macintosh, */
  60. /* it returns a bogus file descriptor */
  61. struct FileSpec*    GetRootFileSpec(void);
  62.  
  63. /* time record */
  64. typedef struct
  65.     {
  66.         unsigned long                    Year : 12;  /* 0..4095 */
  67.         unsigned long                    Month : 4;  /* 0..11 */
  68.         unsigned long                    Day : 5;  /* 0..30 */
  69.         unsigned long                    Hour : 5;  /* 0..23 */
  70.         unsigned long                    Minute : 6;  /* 0..59 */
  71.         unsigned long                    Second : 6;  /* 0..59 */
  72.         unsigned long                    DayOfTheWeek : 3;  /* 0..6 */
  73.     } TimeRec;
  74.  
  75. /* statistics record for a file */
  76. typedef struct
  77.     {
  78.         unsigned long                    CreatorCode;
  79.         unsigned long                    FileTypeCode;
  80.         TimeRec                                CreationDate;
  81.         TimeRec                                LastModificationDate;
  82.     } FileInfoRec;
  83.  
  84. /* get statistics for a file */
  85. MyBoolean                    GetFileStatistics(struct FileSpec* File, FileInfoRec* InfoOut);
  86.  
  87. /* create a new directory with the specified file specification. */
  88. MyBoolean                    CreateNewDirectory(struct FileSpec* DirLocation);
  89.  
  90. /* find out of the specified file specification is a directory */
  91. MyBoolean                    IsTheFileSpecADirectory(struct FileSpec* Spec);
  92.  
  93. /* find out if the specified file is a symbolic link */
  94. MyBoolean                    IsTheFileSpecASymbolicLink(struct FileSpec* Spec);
  95.  
  96. /* obtain a file spec for a file inside of the specified directory.  the file */
  97. /* name must be a non-null-terminated heap block */
  98. struct FileSpec*    FileSpecForFileInDirectory(struct FileSpec* DirLocation,
  99.                                         char* Filename);
  100.  
  101. #endif
  102.