home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / Pedestal / Source / Sources / Files / PedFile.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  916 b   |  65 lines

  1. /* PedFile.cc */
  2.  
  3. #include <Files.h>
  4. #include <Resources.h>
  5.  
  6. #include "DGDebugging.h"
  7.  
  8. #include "PedFSRef.hh"
  9. #include "PedFile.hh"
  10.  
  11. PedFile::PedFile()
  12. : mRef(NULL)/*, mType('????'), mCreator('????')*/
  13. {
  14. }
  15.  
  16. PedFile::PedFile(PedFSRef &inFSRef)
  17. : mRef(&inFSRef)/*, mType('????'), mCreator('????')*/
  18. {
  19. }
  20.  
  21. PedFile::~PedFile()
  22. {
  23. }
  24.  
  25. void
  26. PedFile::SetFSRef(PedFSRef &inRef)
  27. {
  28.     if (mRef) {
  29.         mRef->release();
  30.     }
  31.     mRef = &inRef;
  32.     inRef.retain();
  33. }
  34.  
  35. AccessPath
  36. PedFile::OpenData(SInt8 inPerm) const
  37. {
  38.     OSErr err;
  39.     AccessPath refNum;
  40.     FSSpec spec;
  41.     
  42.     ThrowIfNULL_(mRef);
  43.     spec = mRef->FSS();
  44.     
  45.     err = ::FSpOpenDF(&spec, inPerm, &refNum);
  46.     ThrowIfOSErr_(err);
  47.     return refNum;
  48. }
  49.  
  50. AccessPath
  51. PedFile::OpenResFile(SInt8 inPerm) const
  52. {
  53.     OSErr err;
  54.     AccessPath refNum;
  55.     FSSpec spec;
  56.     
  57.     ThrowIfNULL_(mRef);
  58.     spec = mRef->FSS();
  59.     
  60.     refNum = ::FSpOpenResFile(&spec, inPerm);
  61.     err = ::ResError();
  62.     ThrowIfOSErr_(err);
  63.     return refNum;
  64. }
  65.