home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / BSDFileLib 1.0.2 / BSDFileLib.doc < prev    next >
Encoding:
Text File  |  1997-08-01  |  2.3 KB  |  83 lines  |  [TEXT/CWIE]

  1. BSDFileLib v1.0.2
  2. BuggySoft™ Development
  3. By Scott Dunbar.
  4. © 1997.
  5.  
  6. email:    buggysft@aimnet.com
  7. web:    http://www.aimnet.com/~buggysft/
  8. ftp:    ftp://ftp.aimnet.com/pub/users/buggysft/
  9.  
  10. BSDFileLib is a CodeWarrior 11 library that I made for my own use in a game of ours
  11. called Torture Chamber. You can use this lib free of charge. With this, you can easily read from 
  12. and write to a file.
  13. Call this lib like this:
  14.  
  15. // To Read From A File…
  16. {
  17. Handle    fileData;    // Handle to the file data
  18. short    vRefNum;    // the refNum of the current volume
  19. long    dirID;        // the parent id of the application (just for this example)
  20.     
  21.     fileData = NewHandle(0);    // create an empty handle
  22.     HLock(fileData);    // lock it
  23.     
  24.     HGetVol(nil, vRefNum, dirID);    // get the vRefNum and dirID (where the file is)
  25.     ReadFile(vRefNum, dirID, "\pMy File", fileData);    // read in the file data
  26.     
  27.     // do something with the fileData…
  28.     
  29.     HUnlock(fileData);    // unlock the handle
  30.     DisposeHandle(fileData);    // dispose of it
  31. }
  32.  
  33. // To Write To A File…
  34. {
  35. Handle    fileData;    // Handle to the file data
  36. short    vRefNum;    // the refNum of the current volume
  37. long    dirID;        // the parent id of the application (just for this example)
  38.     
  39.     fileData = NewHandle(0);    // create an empty handle
  40.     HLock(fileData);    // lock it
  41.     
  42.     HGetVol(nil, vRefNum, dirID);    // get the vRefNum and dirID (where the file is)
  43.     WriteFile(vRefNum, dirID, "\pMy File", 'test', 'DATA', fileData);
  44.  
  45.     HUnlock(fileData);    // unlock the handle
  46.     DisposeHandle(fileData);    // dispose of it
  47. }
  48.  
  49. // To Read From A Preferences File…
  50. {
  51. Handle    prefsData;    // Handle to the file data
  52.     
  53.     prefsData = NewHandle(0);    // create an empty handle
  54.     HLock(prefsData);    // lock it
  55.     
  56.     ReadPrefsFile("\pMy Prefs", prefsData);    // read in the pref file data
  57.     
  58.     // do something with the prefsData…
  59.     
  60.     HUnlock(prefsData);    // unlock the handle
  61.     DisposeHandle(prefsData);    // dispose of it
  62. }
  63.  
  64. // To Write To A Preferences File…
  65. {
  66. Handle    prefsData;    // Handle to the file data
  67.     
  68.     prefsData = NewHandle(0);    // create an empty handle
  69.     HLock(prefsData);    // lock it
  70.     
  71.     WritePrefsFile("\pMy Prefs", 'myap', prefsData);
  72.  
  73.     HUnlock(prefsData);    // unlock the handle
  74.     DisposeHandle(prefsData);    // dispose of it
  75. }
  76.  
  77. Those examples will work, but they are pretty much useless.
  78.  
  79. Check out the header, "BSDFileLib.h," for more info on them.
  80. If you would like an example of this lib being used, email me and I'll throw one together.
  81.  
  82. Thanks!
  83.     - Scott Dunbar