home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21246 < prev    next >
Encoding:
Text File  |  1993-01-11  |  5.1 KB  |  115 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!munnari.oz.au!uniwa!cujo!ncrpda.curtin.edu.au!rocky.curtin.edu.au!user
  3. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  4. Subject: Summary: High Level File Manager routines (H-routines)
  5. Message-ID: <peter-120193120945@rocky.curtin.edu.au>
  6. Followup-To: comp.sys.mac.programmer
  7. Lines: 102
  8. Sender: news@ncrpda.curtin.edu.au
  9. Nntp-Posting-Host: ncrpda.curtin.edu.au
  10. Organization: NCRPDA, Curtin University
  11. Date: Tue, 12 Jan 1993 04:17:45 GMT
  12.  
  13. Hi All,
  14.  
  15. Just thought I'd post a list of all the high level routines, maybe it'll
  16. save Jon some answering time! :-)
  17.  
  18. All of these are available in System 6 & 7, and are pasted straight in with
  19. ObiWan - if you don't remember them all, then get ObiWan and look them up
  20. yourself!
  21.  
  22. OSErr:=HCreate(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,creator_OSType,fileType_OSType);
  23. HCreateResFile(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255);
  24. OSErr:=HDelete(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255);
  25. OSErr:=HGetFInfo(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,
  26. VARfndrInfo_FInfo);
  27. OSErr:=HGetVol(volName_StringPtr,VAR_vRefNum_INTEGER,VAR_dirID_LONGINT);
  28. OSErr:=HOpen(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255
  29. ,permission_SignedByte,VAR_refNum_INTEGER);
  30. OSErr:=HOpenDF(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,
  31. permission_SignedByte,VAR_refNum_INTEGER);
  32. INTEGER:=HOpenResFile(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,
  33. permission_SignedByte);
  34. OSErr:=HOpenRF(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,
  35. permission_SignedByte,VAR_refNum_INTEGER);
  36. OSErr:=HRename(vRefNum_INTEGER,dirID_LONGINT,oldName_Str255,newName_Str255);
  37. OSErr:=HSetFInfo(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,fndrInfo_FInfo);
  38. OSErr:=HSetVol(volName_StringPtr,vRefNum_INTEGER,dirID_LONGINT);
  39.  
  40. Under System 7 there are FSp routines as well.  A good way of working under
  41. System 6 & 7 is to use the FSSpec record, and call the routines using those
  42. fields, eg:
  43.  
  44. oe:=HOpen(fs.vRefNum,fs.parID,fs.name,fsRdPerm,refNum);
  45.  
  46. Under System 7 you should use FSMakeFSSpec to create the FSSpec, under
  47. System 6 you need to just fill it out yourself.
  48.  
  49. OSErr:=FSMakeFSSpec(vRefNum_INTEGER,dirID_LONGINT,fileName_Str255,
  50. VAR_spec_FSSpec);
  51.  
  52. If you don't know why you should always be using dirID's, then read on,
  53. especially read FAQ3:
  54.  
  55. Peter's FAQ1 - How do you tell if <modifier>-key is down.
  56. Peter's FAQ2 - How do you get a full pathname.
  57. Peter's FAQ3 - How to learn to love the File Manager.
  58. Peter's NFAQ4 - When do you put ... on the end of a menu item
  59. Peter's FAQ5 - How to set the SFGet/PutFile directory.
  60.  
  61. Peter's FAQ1 - How do you tell if <modifier>-key is down.
  62.    Just call GetNextEvent(noEvent,er), and test the modifiers field 
  63. of the event record.
  64.  
  65. Peter's FAQ2 - How do you get a full pathname.
  66.    Take a look at Tech Note 238, available from ftp.apple.com (and
  67. other places).  It tells you everything you need to know to get a
  68. full pathname, and why you should, in general, use a volume name, 
  69. dirID, filename (and perhaps volume creation date) triple instead.
  70.  
  71. Peter's FAQ3 - How to learn to love the File Manager.
  72.    Its always those pesky wdrn's that are the problem.  Here is a
  73. summary of some of the things to know:
  74.  
  75. vrn=volume reference number (small negative number eg -2)
  76. wdrn=working directory reference number (large negative number eg -32123)
  77. dirID=directory ID (small (but longInt!) positive number eg 4123)
  78.  
  79. vrn's and wdrn's can be used interchangably for the most part.
  80. A vrn represents either a volume, or the root directory of a volume.
  81. A vrn of -1 represents the startup (system) volume.
  82. A wdrn represents a directory on a volume.
  83. Neither a vrn nor a wdrn can be -32768 (TN 77), so use this as your nil
  84. value
  85. A dirID represents nothing without a vrn or a wdrn.
  86. A dirID overrides the directory otherwise specified by the vrn or wdrn 
  87. unless its 0, in which case its ignored.  If it is 2 it specifies the
  88. root directory of the volume. If its 1 it specifies the Desktop directory
  89.  
  90. You should always use vrn,dirID pairs. To convert a wdrn into a vrn,dirID 
  91. pair use this function GetWDInfo, which also returns the volume name.
  92. You can also use GetVol/SetVol to conver volumenames to/from vrns.
  93.  
  94. To store (between invokations of a program) a vrn,dirID pair convert the
  95. vrn to a volume name&creation date (for verification) and store them and
  96. the dirID (and a filename perhaps).
  97.  
  98. Peter's NFAQ4 - When do you put ... on the end of a menu item
  99.    Put an ellipsis (...) at the end of any menu item which requires more 
  100. information in order to complete or simply displays information.  Usually 
  101. this involves a dialog of some kind, be it modal or non modal.
  102.    Leonard Rosenthol <leonardr@svctech.svcdudes.com>, Software Ventures
  103.  
  104. Peter's FAQ5 - How to set the SFGet/PutFile directory.
  105.    To set the directory thats displayed by SFGet/PutFile, stuff the
  106. volume reference number into SFSaveDisk, and the dirID into CurDirStore.
  107.    CurDirStore=$398; Current dirID from Standard File [long] IV-72
  108.    SFSaveDisk=$214; Negative of current vRefNum
  109.  
  110. Have fun all,
  111.    Peter.
  112.  
  113. _______________________________________________________________________
  114. Peter N Lewis <peter@cujo.curtin.edu.au>             Ph: +61 9 368 2055
  115.