home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Peter Lewis / FetchNews 1.0.0b / source / MyFileSystemUtils.unit < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.8 KB  |  75 lines  |  [TEXT/PJMM]

  1. unit MyFileSystemUtils;
  2.  
  3. interface
  4.  
  5.     procedure MyResolveAliasFile (var fs: FSSpec);
  6.     function MyGetCatInfo (vrn: integer; dirID: longInt; var name: string; index: integer; var pb: CInfoPBRec): OSErr;
  7.     function MyFSMakeFSSpec (vrn: integer; dirID: longInt; name: str255; var fs: FSSpec): OSErr;
  8.     procedure MyGetModDate (var fs: FSSpec; var moddate: longInt);
  9.  
  10. implementation
  11.  
  12.     uses
  13.         Aliases;
  14.  
  15.     procedure MyResolveAliasFile (var fs: FSSpec);
  16.         var
  17.             isfolder, wasalias: boolean;
  18.             temp: FSSpec;
  19.             gv: longInt;
  20.             oe: OSErr;
  21.     begin
  22.         if (Gestalt(gestaltAliasMgrAttr, gv) = noErr) & (BTST(gv, gestaltAliasMgrPresent)) then begin
  23.             temp := fs;
  24.             oe := ResolveAliasFile(fs, true, isfolder, wasalias);
  25.             if oe <> noErr then
  26.                 fs := temp;
  27.         end;
  28.     end;
  29.  
  30.     function MyGetCatInfo (vrn: integer; dirID: longInt; var name: string; index: integer; var pb: CInfoPBRec): OSErr;
  31.     begin
  32.         with pb do begin
  33.             ioVRefNum := vrn;
  34.             ioDirID := dirID;
  35.             ioNamePtr := @name;
  36.             ioFDirIndex := index;
  37.             MyGetCatInfo := PBGetCatInfo(@pb, false);
  38.         end;
  39.     end;
  40.  
  41.     function MyFSMakeFSSpec (vrn: integer; dirID: longInt; name: str255; var fs: FSSpec): OSErr;
  42.         var
  43.             pb: CInfoPBRec;
  44.             oe: OSErr;
  45.             gv: longInt;
  46.     begin
  47.         if (Gestalt(gestaltFSAttr, gv) = noErr) & (BTST(gv, gestaltHasFSSpecCalls)) then begin
  48.             oe := FSMakeFSSpec(vrn, dirID, name, fs);
  49.         end
  50.         else begin
  51.             oe := MyGetCatInfo(vrn, dirID, name, 0, pb);
  52.             if (oe = noErr) then begin
  53.                 fs.vRefNum := pb.ioVRefNum;
  54.                 fs.parID := pb.ioFlParID;
  55.                 fs.name := name;
  56.             end;
  57.         end;
  58.         MyFSMakeFSSpec := oe;
  59.     end;
  60.  
  61.     procedure MyGetModDate (var fs: FSSpec; var moddate: longInt);
  62.         var
  63.             oe: OSErr;
  64.             pb: CInfoPBRec;
  65.     begin
  66.         oe := MyGetCatInfo(fs.vRefNum, fs.parID, fs.name, 0, pb);
  67.         if oe = noErr then begin
  68.             moddate := pb.ioFlMdDat
  69.         end
  70.         else begin
  71.             moddate := $80000000;
  72.         end;
  73.     end;
  74.  
  75. end.