vfsmgr.pp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. {$MACRO ON}
  2. {$define Rsc := }
  3. (******************************************************************************
  4. *
  5. * Copyright (c) 2000 Palm, Inc. or its subsidiaries.
  6. * All rights reserved.
  7. *
  8. * File: VFSMgr.h
  9. *
  10. * Release: Palm OS SDK 4.0 (63220)
  11. *
  12. * Description:
  13. * Header file for VFS Manager.
  14. *
  15. * History:
  16. * 02/25/00 jed Created by Jesse Donaldson.
  17. *
  18. *****************************************************************************)
  19. unit vfsmgr;
  20. interface
  21. uses palmos, coretraps, errorbase, datamgr, systemresources;
  22. const
  23. sysTrapVFSMgr = sysTrapFileSystemDispatch;
  24. vfsFtrIDVersion = 0; // ID of feature containing version of VFSMgr.
  25. // Check existence of this feature to see if VFSMgr is installed.
  26. vfsFtrIDDefaultFS = 1; // ID of feature containing the creator ID of the default filesystem library
  27. // this is the default choice when choosing a library for formatting/mounting
  28. vfsMgrVersionNum = UInt16(200); // version of the VFSMgr, obtained from the feature
  29. // MountClass constants:
  30. vfsMountClass_SlotDriver = sysFileTSlotDriver;
  31. vfsMountClass_Simulator = sysFileTSimulator;
  32. vfsMountClass_POSE = Rsc('pose');
  33. // Base MountParamType; others such as SlotMountParamType are extensions of this base type,
  34. // switched on value of "mountClass" parameter. It will make more sense someday when there
  35. // are other kinds of FileSystems... (Trust us. :-)
  36. type
  37. VFSAnyMountParamTag = record
  38. volRefNum: UInt16; // The volRefNum of the volume.
  39. reserved: UInt16;
  40. mountClass: UInt32; // 'libs' for slotDriver-based filesystems
  41. // Other fields here, depending on value of 'mountClass'
  42. end;
  43. VFSAnyMountParamType = VFSAnyMountParamTag;
  44. VFSAnyMountParamPtr = ^VFSAnyMountParamType;
  45. VFSSlotMountParamTag = record
  46. vfsMountParam: VFSAnyMountParamType; // mountClass = VFSMountClass_SlotDriver = 'libs'
  47. slotLibRefNum: UInt16;
  48. slotRefNum: UInt16;
  49. end;
  50. VFSSlotMountParamType = VFSSlotMountParamTag;
  51. VFSPOSEMountParamTag = record
  52. vfsMountParam: VFSAnyMountParamType; // mountClass = VFSMountClass_POSE = 'pose'
  53. poseSlotNum: UInt8;
  54. end;
  55. VFSPOSEMountParamType = VFSPOSEMountParamTag;
  56. (* For Example...
  57. VFSOtherMountParamTag = record
  58. vfsMountParam: VFSAnyMountParamType; // mountClass = 'othr' (for example)
  59. otherValue: UInt16;
  60. end;
  61. VFSOtherMountParamType = VFSOtherMountParamTag;
  62. *)
  63. FileInfoTag = record
  64. attributes: UInt32;
  65. nameP: PChar; // buffer to receive full name; pass NULL to avoid getting name
  66. nameBufLen: UInt16; // size of nameP buffer, in bytes
  67. end;
  68. FileInfoType = FileInfoTag;
  69. FileInfoPtr = ^FileInfoType;
  70. VolumeInfoTag = record
  71. attributes: UInt32; // read-only etc.
  72. fsType: UInt32; // Filesystem type for this volume (defined below)
  73. fsCreator: UInt32; // Creator code of filesystem driver for this volume. For use with VFSCustomControl().
  74. mountClass: UInt32; // mount class that mounted this volume
  75. // For slot based filesystems: (mountClass = vfsMountClass_SlotDriver)
  76. slotLibRefNum: UInt16; // Library on which the volume is mounted
  77. slotRefNum: UInt16; // ExpMgr slot number of card containing volume
  78. mediaType: UInt32; // Type of card media (mediaMemoryStick, mediaCompactFlash, etc...)
  79. reserved: UInt32; // reserved for future use (other mountclasses may need more space)
  80. end;
  81. VolumeInfoType = VolumeInfoTag;
  82. VolumeInfoPtr = ^VolumeInfoType;
  83. type
  84. FileRef = UInt32;
  85. const
  86. vfsInvalidVolRef = 0; // constant for an invalid volume reference, guaranteed not to represent a valid one. Use it like you would use NULL for a FILE*.
  87. vfsInvalidFileRef = 0; // constant for an invalid file reference, guaranteed not to represent a valid one. Use it like you would use NULL for a FILE*.
  88. (************************************************************
  89. * File Origin constants: (for the origins of relative offsets passed to 'seek' type routines).
  90. *************************************************************)
  91. const
  92. vfsOriginBeginning = 0; // from the beginning (first data byte of file)
  93. vfsOriginCurrent = 1; // from the current position
  94. vfsOriginEnd = 2; // from the end of file (one position beyond last data byte, only negative offsets are legal)
  95. type
  96. FileOrigin = UInt16;
  97. (************************************************************
  98. * openMode flags passed to VFSFileOpen
  99. *************************************************************)
  100. const
  101. vfsModeExclusive = $0001; // don't let anyone else open it
  102. vfsModeRead = $0002; // open for read access
  103. vfsModeWrite = $0004 or vfsModeExclusive; // open for write access, implies exclusive
  104. vfsModeCreate = $0008; // create the file if it doesn't already exist. Implemented in VFS layer, no FS lib call will ever have to handle this.
  105. vfsModeTruncate = $0010; // Truncate file to 0 bytes after opening, removing all existing data. Implemented in VFS layer, no FS lib call will ever have to handle this.
  106. vfsModeReadWrite = vfsModeWrite or vfsModeRead; // open for read/write access
  107. vfsModeLeaveOpen = $0020; // Leave the file open even if when the foreground task closes
  108. // Combination flag constants, for error checking purposes:
  109. vfsModeAll = vfsModeExclusive or vfsModeRead or vfsModeWrite or vfsModeCreate or vfsModeTruncate or vfsModeReadWrite or vfsModeLeaveOpen;
  110. vfsModeVFSLayerOnly = vfsModeCreate or vfsModeTruncate; // flags only used apps & the VFS layer, FS libraries will never see these.
  111. (************************************************************
  112. * File Attributes
  113. *************************************************************)
  114. vfsFileAttrReadOnly = $00000001;
  115. vfsFileAttrHidden = $00000002;
  116. vfsFileAttrSystem = $00000004;
  117. vfsFileAttrVolumeLabel = $00000008;
  118. vfsFileAttrDirectory = $00000010;
  119. vfsFileAttrArchive = $00000020;
  120. vfsFileAttrLink = $00000040;
  121. vfsFileAttrAll = $0000007f;
  122. (************************************************************
  123. * Volume Attributes
  124. *************************************************************)
  125. vfsVolumeAttrSlotBased = $00000001; // reserved
  126. vfsVolumeAttrReadOnly = $00000002; // volume is read only
  127. vfsVolumeAttrHidden = $00000004; // volume should not be user-visible.
  128. (************************************************************
  129. * Date constants (for use with VFSFileGet/SetDate)
  130. *************************************************************)
  131. vfsFileDateCreated = 1;
  132. vfsFileDateModified = 2;
  133. vfsFileDateAccessed = 3;
  134. (************************************************************
  135. * Iterator start and stop constants.
  136. * Used by VFSVolumeEnumerate, VFSDirEntryEnumerate, VFSDirEntryEnumerate
  137. *************************************************************)
  138. vfsIteratorStart = 0;
  139. vfsIteratorStop = $ffffffff;
  140. (************************************************************
  141. * 'handled' field bit constants
  142. * (for use with Volume Mounted/Unmounted notifications)
  143. *************************************************************)
  144. vfsHandledUIAppSwitch = $01; // Any UI app switching has already been handled.
  145. // The VFSMgr will not UIAppSwitch to the start.prc app
  146. // (but it will loaded & sent the AutoStart launchcode),
  147. // and the Launcher will not switch to itself.
  148. vfsHandledStartPrc = $02; // And automatic running of start.prc has already been handled.
  149. // VFSMgr will not load it, send it the AutoStart launchcode,
  150. // or UIAppSwitch to it.
  151. (************************************************************
  152. * Format/Mount flags (for use with VFSVolumeFormat/Mount)
  153. *************************************************************)
  154. vfsMountFlagsUseThisFileSystem = $01; // Mount/Format the volume with the filesystem specified
  155. // vfsMountFlagsPrivate1 = $02 // for system use only
  156. // vfsMountFlagsPrivate2 = $04 // for system use only
  157. vfsMountFlagsReserved1 = $08; // reserved
  158. vfsMountFlagsReserved2 = $10; // reserved
  159. vfsMountFlagsReserved3 = $20; // reserved
  160. vfsMountFlagsReserved4 = $40; // reserved
  161. vfsMountFlagsReserved5 = $80; // reserved
  162. (************************************************************
  163. * Common filesystem types. Used by FSFilesystemType and SlotCardIsFilesystemSupported.
  164. *************************************************************)
  165. vfsFilesystemType_VFAT = Rsc('vfat'); // FAT12 and FAT16 extended to handle long file names
  166. vfsFilesystemType_FAT = Rsc('fats'); // FAT12 and FAT16 which only handles 8.3 file names
  167. vfsFilesystemType_NTFS = Rsc('ntfs'); // Windows NT filesystem
  168. vfsFilesystemType_HFSPlus = Rsc('hfse'); // The Macintosh extended hierarchical filesystem
  169. vfsFilesystemType_HFS = Rsc('hfss'); // The Macintosh standard hierarchical filesystem
  170. vfsFilesystemType_MFS = Rsc('mfso'); // The Macintosh original filesystem
  171. vfsFilesystemType_EXT2 = Rsc('ext2'); // Linux filesystem
  172. vfsFilesystemType_FFS = Rsc('ffsb'); // Unix Berkeley block based filesystem
  173. vfsFilesystemType_NFS = Rsc('nfsu'); // Unix Networked filesystem
  174. vfsFilesystemType_AFS = Rsc('afsu'); // Unix Andrew filesystem
  175. vfsFilesystemType_Novell = Rsc('novl'); // Novell filesystem
  176. vfsFilesystemType_HPFS = Rsc('hpfs'); // OS2 High Performance filesystem
  177. (************************************************************
  178. * Error codes
  179. *************************************************************)
  180. vfsErrBufferOverflow = vfsErrorClass or 1; // passed in buffer is too small
  181. vfsErrFileGeneric = vfsErrorClass or 2; // Generic file error.
  182. vfsErrFileBadRef = vfsErrorClass or 3; // the fileref is invalid (has been closed, or was not obtained from VFSFileOpen())
  183. vfsErrFileStillOpen = vfsErrorClass or 4; // returned from FSFileDelete if the file is still open
  184. vfsErrFilePermissionDenied = vfsErrorClass or 5; // The file is read only
  185. vfsErrFileAlreadyExists = vfsErrorClass or 6; // a file of this name exists already in this location
  186. vfsErrFileEOF = vfsErrorClass or 7; // file pointer is at end of file
  187. vfsErrFileNotFound = vfsErrorClass or 8; // file was not found at the path specified
  188. vfsErrVolumeBadRef = vfsErrorClass or 9; // the volume refnum is invalid.
  189. vfsErrVolumeStillMounted = vfsErrorClass or 10; // returned from FSVolumeFormat if the volume is still mounted
  190. vfsErrNoFileSystem = vfsErrorClass or 11; // no installed filesystem supports this operation
  191. vfsErrBadData = vfsErrorClass or 12; // operation could not be completed because of invalid data (i.e., import DB from .PRC file)
  192. vfsErrDirNotEmpty = vfsErrorClass or 13; // can't delete a non-empty directory
  193. vfsErrBadName = vfsErrorClass or 14; // invalid filename, or path, or volume label or something...
  194. vfsErrVolumeFull = vfsErrorClass or 15; // not enough space left on volume
  195. vfsErrUnimplemented = vfsErrorClass or 16; // this call is not implemented
  196. vfsErrNotADirectory = vfsErrorClass or 17; // This operation requires a directory
  197. vfsErrIsADirectory = vfsErrorClass or 18; // This operation requires a regular file, not a directory
  198. vfsErrDirectoryNotFound = vfsErrorClass or 19; // Returned from VFSFileCreate when the path leading up to the new file does not exist
  199. vfsErrNameShortened = vfsErrorClass or 20; // A volume name or filename was automatically shortened to conform to filesystem spec
  200. (************************************************************
  201. * Selectors for routines found in the VFS manager. The order
  202. * of these selectors MUST match the jump table in VFSMgr.c.
  203. *************************************************************)
  204. vfsTrapInit = 0;
  205. vfsTrapCustomControl = 1;
  206. vfsTrapFileCreate = 2;
  207. vfsTrapFileOpen = 3;
  208. vfsTrapFileClose = 4;
  209. vfsTrapFileReadData = 5;
  210. vfsTrapFileRead = 6;
  211. vfsTrapFileWrite = 7;
  212. vfsTrapFileDelete = 8;
  213. vfsTrapFileRename = 9;
  214. vfsTrapFileSeek = 10;
  215. vfsTrapFileEOF = 11;
  216. vfsTrapFileTell = 12;
  217. vfsTrapFileResize = 13;
  218. vfsTrapFileGetAttributes = 14;
  219. vfsTrapFileSetAttributes = 15;
  220. vfsTrapFileGetDate = 16;
  221. vfsTrapFileSetDate = 17;
  222. vfsTrapFileSize = 18;
  223. vfsTrapDirCreate = 19;
  224. vfsTrapDirEntryEnumerate = 20;
  225. vfsTrapGetDefaultDirectory = 21;
  226. vfsTrapRegisterDefaultDirectory = 22;
  227. vfsTrapUnregisterDefaultDirectory = 23;
  228. vfsTrapVolumeFormat = 24;
  229. vfsTrapVolumeMount = 25;
  230. vfsTrapVolumeUnmount = 26;
  231. vfsTrapVolumeEnumerate = 27;
  232. vfsTrapVolumeInfo = 28;
  233. vfsTrapVolumeGetLabel = 29;
  234. vfsTrapVolumeSetLabel = 30;
  235. vfsTrapVolumeSize = 31;
  236. vfsTrapInstallFSLib = 32;
  237. vfsTrapRemoveFSLib = 33;
  238. vfsTrapImportDatabaseFromFile = 34;
  239. vfsTrapExportDatabaseToFile = 35;
  240. vfsTrapFileDBGetResource = 36;
  241. vfsTrapFileDBInfo = 37;
  242. vfsTrapFileDBGetRecord = 38;
  243. vfsTrapImportDatabaseFromFileCustom = 39;
  244. vfsTrapExportDatabaseToFileCustom = 40;
  245. // System use only
  246. vfsTrapPrivate1 = 41;
  247. vfsMaxSelector = vfsTrapPrivate1;
  248. type
  249. VFSImportProcPtr = function(totalBytes, offset: UInt32; userDataP: Pointer): Err;
  250. VFSExportProcPtr = function(totalBytes, offset: UInt32; userDataP: Pointer): Err;
  251. function VFSInit: Err;
  252. // if you pass NULL for fsCreator, VFS will iterate through
  253. // all installed filesystems until it finds one that does not return an error.
  254. function VFSCustomControl(fsCreator, apiCreator: UInt32; apiSelector: UInt16;
  255. valueP: Pointer; var valueLenP: UInt16): Err;
  256. function VFSFileCreate(volRefNum: UInt16; const pathNameP: PChar): Err;
  257. function VFSFileOpen(volRefNum: UInt16; const pathNameP: PChar; openMode: UInt16; var fileRefP: FileRef): Err;
  258. function VFSFileClose(fileRef: FileRef): Err;
  259. function VFSFileReadData(fileRef: FileRef; numBytes: UInt32; bufBaseP: Pointer;
  260. offset: UInt32; var numBytesReadP: UInt32): Err;
  261. function VFSFileRead(fileRef: FileRef; numBytes: UInt32; bufP: Pointer; var numBytesReadP: UInt32): Err;
  262. function VFSFileWrite(fileRef: FileRef; numBytes: UInt32; const dataP: Pointer; var numBytesWrittenP: UInt32): Err;
  263. // some file routines work on directories
  264. function VFSFileDelete(volRefNum: UInt16; const pathNameP: PChar): Err;
  265. function VFSFileRename(volRefNum: UInt16; const pathNameP, newNameP: PChar): Err;
  266. function VFSFileSeek(fileRef: FileRef; origin: FileOrigin; offset: Int32): Err;
  267. function VFSFileEOF(fileRef: FileRef): Err;
  268. function VFSFileTell(fileRef: FileRef; var filePosP: UInt32): Err;
  269. function VFSFileSize(fileRef: FileRef; var fileSizeP: UInt32): Err;
  270. function VFSFileResize(fileRef: FileRef; newSize: UInt32): Err;
  271. function VFSFileGetAttributes(fileRef: FileRef; var attributesP: UInt32): Err;
  272. function VFSFileSetAttributes(fileRef: FileRef; attributes: UInt32): Err;
  273. function VFSFileGetDate(fileRef: FileRef; whichDate: UInt16; var dateP: UInt32): Err;
  274. function VFSFileSetDate(fileRef: FileRef; whichDate: UInt16; date: UInt32): Err;
  275. function VFSDirCreate(volRefNum: UInt16; const dirNameP: PChar): Err;
  276. function VFSDirEntryEnumerate(dirRef: FileRef; var dirEntryIteratorP: UInt32; var infoP: FileInfoType): Err;
  277. function VFSGetDefaultDirectory(volRefNum: UInt16; const fileTypeStr: PChar;
  278. pathStr: PChar; var bufLenP: UInt16): Err;
  279. function VFSRegisterDefaultDirectory(const fileTypeStr: PChar; mediaType: UInt32;
  280. const pathStr: PChar): Err;
  281. function VFSUnregisterDefaultDirectory(const fileTypeStr: PChar; mediaType: UInt32): Err;
  282. function VFSVolumeFormat(flags: UInt8; fsLibRefNum: UInt16; vfsMountParamP: VFSAnyMountParamPtr): Err;
  283. function VFSVolumeMount(flags: UInt8; fsLibRefNum: UInt16; vfsMountParamP: VFSAnyMountParamPtr): Err;
  284. function VFSVolumeUnmount(volRefNum: UInt16): Err;
  285. function VFSVolumeEnumerate(var volRefNumP: UInt16; var volIteratorP: UInt32): Err;
  286. function VFSVolumeInfo(volRefNum: UInt16; var volInfoP: VolumeInfoType): Err;
  287. function VFSVolumeGetLabel(volRefNum: UInt16; labelP: PChar; bufLen: UInt16): Err;
  288. function VFSVolumeSetLabel(volRefNum: UInt16; const labelP: PChar): Err;
  289. function VFSVolumeSize(volRefNum: UInt16; var volumeUsedP, volumeTotalP: UInt32): Err;
  290. function VFSInstallFSLib(creator: UInt32; var fsLibRefNumP: UInt16): Err;
  291. function VFSRemoveFSLib(fsLibRefNum: UInt16): Err;
  292. function VFSImportDatabaseFromFile(volRefNum: UInt16; const pathNameP: PChar;
  293. var cardNoP: UInt16; var dbIDP: LocalID): Err;
  294. function VFSImportDatabaseFromFileCustom(volRefNum: UInt16; const pathNameP: PChar;
  295. var cardNoP: UInt16; var dbIDP: LocalID;
  296. importProcP: VFSImportProcPtr; userDataP: Pointer): Err;
  297. function VFSExportDatabaseToFile(volRefNum: UInt16; const pathNameP: PChar;
  298. cardNo: UInt16; dbID: LocalID): Err;
  299. function VFSExportDatabaseToFileCustom(volRefNum: UInt16; const pathNameP: PChar;
  300. cardNo: UInt16; dbID: LocalID;
  301. exportProcP: VFSExportProcPtr; userDataP: Pointer): Err;
  302. function VFSFileDBGetResource(ref: FileRef; type_: DmResType; resID: DmResID; var resHP: MemHandle): Err;
  303. function VFSFileDBInfo(ref: FileRef; nameP: PChar; var attributesP, versionP: UInt16;
  304. var crDateP, modDateP, bckUpDateP, modNumP: UInt32;
  305. var appInfoHP, sortInfoHP: MemHandle; var typeP, creatorP: UInt32;
  306. var numRecordsP: UInt16): Err;
  307. function VFSFileDBGetRecord(ref: FileRef; recIndex: UInt16; var recHP: MemHandle;
  308. var recAttrP: UInt8; var uniqueIDP: UInt32): Err;
  309. implementation
  310. (**)
  311. function __VFSInit: Err; syscall sysTrapVFSMgr;
  312. function __VFSCustomControl(fsCreator, apiCreator: UInt32; apiSelector: UInt16;
  313. valueP: Pointer; var valueLenP: UInt16): Err; syscall sysTrapVFSMgr;
  314. function __VFSFileCreate(volRefNum: UInt16; const pathNameP: PChar): Err; syscall sysTrapVFSMgr;
  315. function __VFSFileOpen(volRefNum: UInt16; const pathNameP: PChar; openMode: UInt16; var fileRefP: FileRef): Err; syscall sysTrapVFSMgr;
  316. function __VFSFileClose(fileRef: FileRef): Err; syscall sysTrapVFSMgr;
  317. function __VFSFileReadData(fileRef: FileRef; numBytes: UInt32; bufBaseP: Pointer;
  318. offset: UInt32; var numBytesReadP: UInt32): Err; syscall sysTrapVFSMgr;
  319. function __VFSFileRead(fileRef: FileRef; numBytes: UInt32; bufP: Pointer; var numBytesReadP: UInt32): Err; syscall sysTrapVFSMgr;
  320. function __VFSFileWrite(fileRef: FileRef; numBytes: UInt32; const dataP: Pointer; var numBytesWrittenP: UInt32): Err; syscall sysTrapVFSMgr;
  321. // some file routines work on directories
  322. function __VFSFileDelete(volRefNum: UInt16; const pathNameP: PChar): Err; syscall sysTrapVFSMgr;
  323. function __VFSFileRename(volRefNum: UInt16; const pathNameP, newNameP: PChar): Err; syscall sysTrapVFSMgr;
  324. function __VFSFileSeek(fileRef: FileRef; origin: FileOrigin; offset: Int32): Err; syscall sysTrapVFSMgr;
  325. function __VFSFileEOF(fileRef: FileRef): Err; syscall sysTrapVFSMgr;
  326. function __VFSFileTell(fileRef: FileRef; var filePosP: UInt32): Err; syscall sysTrapVFSMgr;
  327. function __VFSFileSize(fileRef: FileRef; var fileSizeP: UInt32): Err; syscall sysTrapVFSMgr;
  328. function __VFSFileResize(fileRef: FileRef; newSize: UInt32): Err; syscall sysTrapVFSMgr;
  329. function __VFSFileGetAttributes(fileRef: FileRef; var attributesP: UInt32): Err; syscall sysTrapVFSMgr;
  330. function __VFSFileSetAttributes(fileRef: FileRef; attributes: UInt32): Err; syscall sysTrapVFSMgr;
  331. function __VFSFileGetDate(fileRef: FileRef; whichDate: UInt16; var dateP: UInt32): Err; syscall sysTrapVFSMgr;
  332. function __VFSFileSetDate(fileRef: FileRef; whichDate: UInt16; date: UInt32): Err; syscall sysTrapVFSMgr;
  333. function __VFSDirCreate(volRefNum: UInt16; const dirNameP: PChar): Err; syscall sysTrapVFSMgr;
  334. function __VFSDirEntryEnumerate(dirRef: FileRef; var dirEntryIteratorP: UInt32; var infoP: FileInfoType): Err; syscall sysTrapVFSMgr;
  335. function __VFSGetDefaultDirectory(volRefNum: UInt16; const fileTypeStr: PChar;
  336. pathStr: PChar; var bufLenP: UInt16): Err; syscall sysTrapVFSMgr;
  337. function __VFSRegisterDefaultDirectory(const fileTypeStr: PChar; mediaType: UInt32;
  338. const pathStr: PChar): Err; syscall sysTrapVFSMgr;
  339. function __VFSUnregisterDefaultDirectory(const fileTypeStr: PChar; mediaType: UInt32): Err; syscall sysTrapVFSMgr;
  340. function __VFSVolumeFormat(flags: UInt8; fsLibRefNum: UInt16; vfsMountParamP: VFSAnyMountParamPtr): Err; syscall sysTrapVFSMgr;
  341. function __VFSVolumeMount(flags: UInt8; fsLibRefNum: UInt16; vfsMountParamP: VFSAnyMountParamPtr): Err; syscall sysTrapVFSMgr;
  342. function __VFSVolumeUnmount(volRefNum: UInt16): Err; syscall sysTrapVFSMgr;
  343. function __VFSVolumeEnumerate(var volRefNumP: UInt16; var volIteratorP: UInt32): Err; syscall sysTrapVFSMgr;
  344. function __VFSVolumeInfo(volRefNum: UInt16; var volInfoP: VolumeInfoType): Err; syscall sysTrapVFSMgr;
  345. function __VFSVolumeGetLabel(volRefNum: UInt16; labelP: PChar; bufLen: UInt16): Err; syscall sysTrapVFSMgr;
  346. function __VFSVolumeSetLabel(volRefNum: UInt16; const labelP: PChar): Err; syscall sysTrapVFSMgr;
  347. function __VFSVolumeSize(volRefNum: UInt16; var volumeUsedP, volumeTotalP: UInt32): Err; syscall sysTrapVFSMgr;
  348. function __VFSInstallFSLib(creator: UInt32; var fsLibRefNumP: UInt16): Err; syscall sysTrapVFSMgr;
  349. function __VFSRemoveFSLib(fsLibRefNum: UInt16): Err; syscall sysTrapVFSMgr;
  350. function __VFSImportDatabaseFromFile(volRefNum: UInt16; const pathNameP: PChar;
  351. var cardNoP: UInt16; var dbIDP: LocalID): Err; syscall sysTrapVFSMgr;
  352. function __VFSImportDatabaseFromFileCustom(volRefNum: UInt16; const pathNameP: PChar;
  353. var cardNoP: UInt16; var dbIDP: LocalID;
  354. importProcP: VFSImportProcPtr; userDataP: Pointer): Err; syscall sysTrapVFSMgr;
  355. function __VFSExportDatabaseToFile(volRefNum: UInt16; const pathNameP: PChar;
  356. cardNo: UInt16; dbID: LocalID): Err; syscall sysTrapVFSMgr;
  357. function __VFSExportDatabaseToFileCustom(volRefNum: UInt16; const pathNameP: PChar;
  358. cardNo: UInt16; dbID: LocalID;
  359. exportProcP: VFSExportProcPtr; userDataP: Pointer): Err; syscall sysTrapVFSMgr;
  360. function __VFSFileDBGetResource(ref: FileRef; type_: DmResType; resID: DmResID; var resHP: MemHandle): Err; syscall sysTrapVFSMgr;
  361. function __VFSFileDBInfo(ref: FileRef; nameP: PChar; var attributesP, versionP: UInt16;
  362. var crDateP, modDateP, bckUpDateP, modNumP: UInt32;
  363. var appInfoHP, sortInfoHP: MemHandle; var typeP, creatorP: UInt32;
  364. var numRecordsP: UInt16): Err; syscall sysTrapVFSMgr;
  365. function __VFSFileDBGetRecord(ref: FileRef; recIndex: UInt16; var recHP: MemHandle;
  366. var recAttrP: UInt8; var uniqueIDP: UInt32): Err; syscall sysTrapVFSMgr;
  367. (**)
  368. function VFSInit: Err;
  369. begin
  370. asm
  371. move.l #$vfsTrapInit, D2;
  372. end;
  373. VFSInit := __VFSInit;
  374. end;
  375. function VFSCustomControl(fsCreator, apiCreator: UInt32; apiSelector: UInt16;
  376. valueP: Pointer; var valueLenP: UInt16): Err;
  377. begin
  378. asm
  379. move.l #$vfsTrapCustomControl, D2;
  380. end;
  381. VFSCustomControl := __VFSCustomControl(fsCreator, apiCreator, apiSelector, valueP, valueLenP);
  382. end;
  383. function VFSFileCreate(volRefNum: UInt16; const pathNameP: PChar): Err;
  384. begin
  385. asm
  386. move.l #$vfsTrapFileCreate, D2;
  387. end;
  388. VFSFileCreate := __VFSFileCreate(volRefNum, pathNameP);
  389. end;
  390. function VFSFileOpen(volRefNum: UInt16; const pathNameP: PChar; openMode: UInt16; var fileRefP: FileRef): Err;
  391. begin
  392. asm
  393. move.l #$vfsTrapFileOpen, D2;
  394. end;
  395. VFSFileOpen := __VFSFileOpen(volRefNum, pathNameP, openMode, fileRefP);
  396. end;
  397. function VFSFileClose(fileRef: FileRef): Err;
  398. begin
  399. asm
  400. move.l #$vfsTrapFileClose, D2;
  401. end;
  402. VFSFileClose := __VFSFileClose(fileRef);
  403. end;
  404. function VFSFileReadData(fileRef: FileRef; numBytes: UInt32; bufBaseP: Pointer;
  405. offset: UInt32; var numBytesReadP: UInt32): Err;
  406. begin
  407. asm
  408. move.l #$vfsTrapFileReadData, D2;
  409. end;
  410. VFSFileReadData := __VFSFileReadData(fileRef, numBytes, bufBaseP, offset, numBytesReadP);
  411. end;
  412. function VFSFileRead(fileRef: FileRef; numBytes: UInt32; bufP: Pointer; var numBytesReadP: UInt32): Err;
  413. begin
  414. asm
  415. move.l #$vfsTrapFileRead, D2;
  416. end;
  417. VFSFileRead := __VFSFileRead(fileRef, numBytes, bufP, numBytesReadP);
  418. end;
  419. function VFSFileWrite(fileRef: FileRef; numBytes: UInt32; const dataP: Pointer; var numBytesWrittenP: UInt32): Err;
  420. begin
  421. asm
  422. move.l #$vfsTrapFileWrite, D2;
  423. end;
  424. VFSFileWrite := __VFSFileWrite(fileRef, numBytes, dataP, numBytesWrittenP);
  425. end;
  426. function VFSFileDelete(volRefNum: UInt16; const pathNameP: PChar): Err;
  427. begin
  428. asm
  429. move.l #$vfsTrapFileDelete, D2;
  430. end;
  431. VFSFileDelete := __VFSFileDelete(volRefNum, pathNameP);
  432. end;
  433. function VFSFileRename(volRefNum: UInt16; const pathNameP, newNameP: PChar): Err;
  434. begin
  435. asm
  436. move.l #$vfsTrapFileRename, D2;
  437. end;
  438. VFSFileRename := __VFSFileRename(volRefNum, pathNameP, newNameP);
  439. end;
  440. function VFSFileSeek(fileRef: FileRef; origin: FileOrigin; offset: Int32): Err;
  441. begin
  442. asm
  443. move.l #$vfsTrapFileSeek, D2;
  444. end;
  445. VFSFileSeek := __VFSFileSeek(fileRef, origin, offset);
  446. end;
  447. function VFSFileEOF(fileRef: FileRef): Err;
  448. begin
  449. asm
  450. move.l #$vfsTrapFileEOF, D2;
  451. end;
  452. VFSFileEOF := __VFSFileEOF(fileRef);
  453. end;
  454. function VFSFileTell(fileRef: FileRef; var filePosP: UInt32): Err;
  455. begin
  456. asm
  457. move.l #$vfsTrapFileTell, D2;
  458. end;
  459. VFSFileTell := __VFSFileTell(fileRef, filePosP);
  460. end;
  461. function VFSFileSize(fileRef: FileRef; var fileSizeP: UInt32): Err;
  462. begin
  463. asm
  464. move.l #$vfsTrapFileSize, D2;
  465. end;
  466. VFSFileSize := __VFSFileSize(fileRef, fileSizeP);
  467. end;
  468. function VFSFileResize(fileRef: FileRef; newSize: UInt32): Err;
  469. begin
  470. asm
  471. move.l #$vfsTrapFileResize, D2;
  472. end;
  473. VFSFileResize := __VFSFileResize(fileRef, newSize);
  474. end;
  475. function VFSFileGetAttributes(fileRef: FileRef; var attributesP: UInt32): Err;
  476. begin
  477. asm
  478. move.l #$vfsTrapFileGetAttributes, D2;
  479. end;
  480. VFSFileGetAttributes := __VFSFileGetAttributes(fileRef, attributesP);
  481. end;
  482. function VFSFileSetAttributes(fileRef: FileRef; attributes: UInt32): Err;
  483. begin
  484. asm
  485. move.l #$vfsTrapFileSetAttributes, D2;
  486. end;
  487. VFSFileSetAttributes := __VFSFileSetAttributes(fileRef, attributes);
  488. end;
  489. function VFSFileGetDate(fileRef: FileRef; whichDate: UInt16; var dateP: UInt32): Err;
  490. begin
  491. asm
  492. move.l #$vfsTrapFileGetDate, D2;
  493. end;
  494. VFSFileGetDate := __VFSFileGetDate(fileRef, whichDate, dateP);
  495. end;
  496. function VFSFileSetDate(fileRef: FileRef; whichDate: UInt16; date: UInt32): Err;
  497. begin
  498. asm
  499. move.l #$vfsTrapFileSetDate, D2;
  500. end;
  501. VFSFileSetDate := __VFSFileSetDate(fileRef, whichDate, date);
  502. end;
  503. function VFSDirCreate(volRefNum: UInt16; const dirNameP: PChar): Err;
  504. begin
  505. asm
  506. move.l #$vfsTrapDirCreate, D2;
  507. end;
  508. VFSDirCreate := __VFSDirCreate(volRefNum, dirNameP);
  509. end;
  510. function VFSDirEntryEnumerate(dirRef: FileRef; var dirEntryIteratorP: UInt32; var infoP: FileInfoType): Err;
  511. begin
  512. asm
  513. move.l #$vfsTrapDirEntryEnumerate, D2;
  514. end;
  515. VFSDirEntryEnumerate := __VFSDirEntryEnumerate(dirRef, dirEntryIteratorP, infoP);
  516. end;
  517. function VFSGetDefaultDirectory(volRefNum: UInt16; const fileTypeStr: PChar;
  518. pathStr: PChar; var bufLenP: UInt16): Err;
  519. begin
  520. asm
  521. move.l #$vfsTrapGetDefaultDirectory, D2;
  522. end;
  523. VFSGetDefaultDirectory := __VFSGetDefaultDirectory(volRefNum, fileTypeStr, pathStr, bufLenP);
  524. end;
  525. function VFSRegisterDefaultDirectory(const fileTypeStr: PChar; mediaType: UInt32;
  526. const pathStr: PChar): Err;
  527. begin
  528. asm
  529. move.l #$vfsTrapRegisterDefaultDirectory, D2;
  530. end;
  531. VFSRegisterDefaultDirectory := __VFSRegisterDefaultDirectory(fileTypeStr, mediaType, pathStr);
  532. end;
  533. function VFSUnregisterDefaultDirectory(const fileTypeStr: PChar; mediaType: UInt32): Err;
  534. begin
  535. asm
  536. move.l #$vfsTrapUnregisterDefaultDirectory, D2;
  537. end;
  538. VFSUnregisterDefaultDirectory := __VFSUnregisterDefaultDirectory(fileTypeStr, mediaType);
  539. end;
  540. function VFSVolumeFormat(flags: UInt8; fsLibRefNum: UInt16; vfsMountParamP: VFSAnyMountParamPtr): Err;
  541. begin
  542. asm
  543. move.l #$vfsTrapVolumeFormat, D2;
  544. end;
  545. VFSVolumeFormat := __VFSVolumeFormat(flags, fsLibRefNum, vfsMountParamP);
  546. end;
  547. function VFSVolumeMount(flags: UInt8; fsLibRefNum: UInt16; vfsMountParamP: VFSAnyMountParamPtr): Err;
  548. begin
  549. asm
  550. move.l #$vfsTrapVolumeMount, D2;
  551. end;
  552. VFSVolumeMount := __VFSVolumeMount(flags, fsLibRefNum, vfsMountParamP);
  553. end;
  554. function VFSVolumeUnmount(volRefNum: UInt16): Err;
  555. begin
  556. asm
  557. move.l #$vfsTrapVolumeUnmount, D2;
  558. end;
  559. VFSVolumeUnmount := __VFSVolumeUnmount(volRefNum);
  560. end;
  561. function VFSVolumeEnumerate(var volRefNumP: UInt16; var volIteratorP: UInt32): Err;
  562. begin
  563. asm
  564. move.l #$vfsTrapVolumeEnumerate, D2;
  565. end;
  566. VFSVolumeEnumerate := __VFSVolumeEnumerate(volRefNumP, volIteratorP);
  567. end;
  568. function VFSVolumeInfo(volRefNum: UInt16; var volInfoP: VolumeInfoType): Err;
  569. begin
  570. asm
  571. move.l #$vfsTrapVolumeInfo, D2;
  572. end;
  573. VFSVolumeInfo := __VFSVolumeInfo(volRefNum, volInfoP);
  574. end;
  575. function VFSVolumeGetLabel(volRefNum: UInt16; labelP: PChar; bufLen: UInt16): Err;
  576. begin
  577. asm
  578. move.l #$vfsTrapVolumeGetLabel, D2;
  579. end;
  580. VFSVolumeGetLabel := __VFSVolumeGetLabel(volRefNum, labelP, bufLen);
  581. end;
  582. function VFSVolumeSetLabel(volRefNum: UInt16; const labelP: PChar): Err;
  583. begin
  584. asm
  585. move.l #$vfsTrapVolumeSetLabel, D2;
  586. end;
  587. VFSVolumeSetLabel := __VFSVolumeSetLabel(volRefNum, labelP);
  588. end;
  589. function VFSVolumeSize(volRefNum: UInt16; var volumeUsedP, volumeTotalP: UInt32): Err;
  590. begin
  591. asm
  592. move.l #$vfsTrapVolumeSize, D2;
  593. end;
  594. VFSVolumeSize := __VFSVolumeSize(volRefNum, volumeUsedP, volumeTotalP);
  595. end;
  596. function VFSInstallFSLib(creator: UInt32; var fsLibRefNumP: UInt16): Err;
  597. begin
  598. asm
  599. move.l #$vfsTrapInstallFSLib, D2;
  600. end;
  601. VFSInstallFSLib := __VFSInstallFSLib(creator, fsLibRefNumP);
  602. end;
  603. function VFSRemoveFSLib(fsLibRefNum: UInt16): Err;
  604. begin
  605. asm
  606. move.l #$vfsTrapRemoveFSLib, D2;
  607. end;
  608. VFSRemoveFSLib := __VFSRemoveFSLib(fsLibRefNum);
  609. end;
  610. function VFSImportDatabaseFromFile(volRefNum: UInt16; const pathNameP: PChar;
  611. var cardNoP: UInt16; var dbIDP: LocalID): Err;
  612. begin
  613. asm
  614. move.l #$vfsTrapImportDatabaseFromFile, D2;
  615. end;
  616. VFSImportDatabaseFromFile := __VFSImportDatabaseFromFile(volRefNum, pathNameP, cardNoP, dbIDP);
  617. end;
  618. function VFSImportDatabaseFromFileCustom(volRefNum: UInt16; const pathNameP: PChar;
  619. var cardNoP: UInt16; var dbIDP: LocalID;
  620. importProcP: VFSImportProcPtr; userDataP: Pointer): Err;
  621. begin
  622. asm
  623. move.l #$vfsTrapImportDatabaseFromFileCustom, D2;
  624. end;
  625. VFSImportDatabaseFromFileCustom := __VFSImportDatabaseFromFileCustom(volRefNum, pathNameP,
  626. cardNoP, dbIDP, importProcP, userDataP);
  627. end;
  628. function VFSExportDatabaseToFile(volRefNum: UInt16; const pathNameP: PChar;
  629. cardNo: UInt16; dbID: LocalID): Err;
  630. begin
  631. asm
  632. move.l #$vfsTrapExportDatabaseToFile, D2;
  633. end;
  634. VFSExportDatabaseToFile := __VFSExportDatabaseToFile(volRefNum, pathNameP, cardNo, dbID);
  635. end;
  636. function VFSExportDatabaseToFileCustom(volRefNum: UInt16; const pathNameP: PChar;
  637. cardNo: UInt16; dbID: LocalID;
  638. exportProcP: VFSExportProcPtr; userDataP: Pointer): Err;
  639. begin
  640. asm
  641. move.l #$vfsTrapExportDatabaseToFileCustom, D2;
  642. end;
  643. VFSExportDatabaseToFileCustom := __VFSExportDatabaseToFileCustom(volRefNum, pathNameP,
  644. cardNo, dbID, exportProcP, userDataP);
  645. end;
  646. function VFSFileDBGetResource(ref: FileRef; type_: DmResType; resID: DmResID; var resHP: MemHandle): Err;
  647. begin
  648. asm
  649. move.l #$vfsTrapFileDBGetResource, D2;
  650. end;
  651. VFSFileDBGetResource := __VFSFileDBGetResource(ref, type_, resID, resHP);
  652. end;
  653. function VFSFileDBInfo(ref: FileRef; nameP: PChar; var attributesP, versionP: UInt16;
  654. var crDateP, modDateP, bckUpDateP, modNumP: UInt32;
  655. var appInfoHP, sortInfoHP: MemHandle; var typeP, creatorP: UInt32;
  656. var numRecordsP: UInt16): Err;
  657. begin
  658. asm
  659. move.l #$vfsTrapFileDBInfo, D2;
  660. end;
  661. VFSFileDBInfo := __VFSFileDBInfo(ref, nameP, attributesP, versionP, crDateP, modDateP,
  662. bckUpDateP, modNumP, appInfoHP, sortInfoHP, typeP, creatorP, numRecordsP);
  663. end;
  664. function VFSFileDBGetRecord(ref: FileRef; recIndex: UInt16; var recHP: MemHandle;
  665. var recAttrP: UInt8; var uniqueIDP: UInt32): Err;
  666. begin
  667. asm
  668. move.l #$vfsTrapFileDBGetRecord, D2;
  669. end;
  670. VFSFileDBGetRecord := __VFSFileDBGetRecord(ref, recIndex, recHP, recAttrP, uniqueIDP);
  671. end;
  672. end.