filelib.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. ;-------------------------------------------------------------
  2. ; Filelib: file/folder operations functions
  3. ; by the Doors Team
  4. ; xvassor@mail.dotcom.fr or deucalion@mail.dotcom.fr
  5. ; http://start.at/doors
  6. ;-------------------------------------------------------------
  7. ;Before using this library, it would be better if you read some doc
  8. ;about the TI89/TI92+ VAT (Variable Allocation Table).
  9. ;You can probably find docs at TiCalc.org
  10. ; http://www.ticalc.org
  11. ;NOTE: If you want to use these functions on a folder
  12. ; you have to do: "moveq.w #doorsos::FolderListHandle,d0"
  13. ;NOTE2: the index of a file(or a folder) is its place in the
  14. ;file(or folder) list.
  15. ;for example if you have the following file list:
  16. ; filelib
  17. ; graphlib
  18. ; shell
  19. ; userlib
  20. ;Then the index of filelib is 0, the index of graphlib is 1...
  21. ;When d2=result is output it has the following values:
  22. ; 0 -> error
  23. ; 1 -> OK
  24. filelib::sortlist equ filelib@0000
  25. ;--------------------------------------------------------------
  26. ;sortlist(list handle)
  27. ;
  28. ; Sorts file/folder list d0 in alphabetical order
  29. ;
  30. ;Input: d0.w = file/folder list handle
  31. ;
  32. ;Output: nothing
  33. ;
  34. ; NO REGISTERS DESTROYED
  35. ;--------------------------------------------------------------
  36. filelib::delete equ filelib@0001
  37. ;--------------------------------------------------------------
  38. ;delete(folder,file/folder)
  39. ;
  40. ; Deletes the file/folder d1 in folder d0
  41. ;
  42. ;Input: d0.w = folder handle
  43. ; d1.w = file/folder index
  44. ;
  45. ;Output: d2.w = result
  46. :
  47. ; NO REGISTERS DESTROYED
  48. ;--------------------------------------------------------------
  49. filelib::copy equ filelib@0002
  50. ;--------------------------------------------------------------
  51. ;copy(folder,file,newfolder)
  52. ;
  53. ; Copies the file d1 in folder d0 to folder d2
  54. ;
  55. ;Input:d0.w = source folder handle
  56. ; d1.w = file index
  57. ; d2.w = dest folder handle
  58. ;
  59. ;Output: d2.w = result
  60. ; NO OTHER REGISTERS DESTROYED
  61. ;--------------------------------------------------------------
  62. filelib::move equ filelib@0003
  63. ;--------------------------------------------------------------
  64. ;move(folder,file,newfolder)
  65. ;
  66. ; Moves the file d1 in folder d0 to folder d2
  67. ;
  68. ;Input:d0.w = source folder handle
  69. ; d1.w = file index
  70. ; d2.w = dest folder handle
  71. ;
  72. ;Output:d2.w = result
  73. ; NO REGISTERS DESTROYED
  74. ;
  75. ;--------------------------------------------------------------
  76. filelib::rename equ filelib@0004
  77. ;--------------------------------------------------------------
  78. ;rename(folder,file/folder,newname)
  79. ;
  80. ; Renames the file/folder d1 in folder d0 with new name a0
  81. ;
  82. ;Input: d0.w = folder handle
  83. ; d1.w = file/folder index
  84. ; a0.l = adress of the new name
  85. ;
  86. ;Output: d2.w = result
  87. ; NO REGISTERS DESTROYED
  88. ;--------------------------------------------------------------
  89. filelib::createfolder equ filelib@0005
  90. ;--------------------------------------------------------------
  91. ;createfolder(name)
  92. ;
  93. ; Creates a new folder
  94. ;
  95. ;Input: a0.l = name of the folder
  96. ;
  97. ;Output: d2.w = result
  98. ;
  99. ; NO REGISTERS DESTROYED
  100. ;--------------------------------------------------------------
  101. filelib::protect equ filelib@0006
  102. ;-------------------------------------------------------------
  103. ;protect(folder,file/folder)
  104. ;
  105. ; Protects the file/folder d1 in folder d0 so that this file
  106. ; is unreacheable in TI OS and quite invisible in ASM programs
  107. ; You can access it again only with the Doors shell
  108. ;
  109. ;Input: d0.w = folder handle
  110. ; d1.w = file/folder index
  111. ;
  112. ;Output: d2.w = result
  113. ; NO REGISTERS DESTROYED
  114. ;--------------------------------------------------------------
  115. filelib::hide equ filelib@0007
  116. ;--------------------------------------------------------------
  117. ;hide(folder,file/folder)
  118. ;
  119. ; used on a file, this function makes it disappear from TIOS
  120. ; used on a folder, this function hides it in the Var-Link
  121. ; But the file is always appears in ASM programs
  122. ;Input: d0.w = folder handle
  123. ; d1.w = file/folder index
  124. ;
  125. ;Output: nothing
  126. ;--------------------------------------------------------------
  127. filelib::unhide equ filelib@0008
  128. ;--------------------------------------------------------------
  129. ;unhide(folder,file/folder)
  130. ;
  131. ; Cancelles the effects of hide
  132. ;
  133. ;Input: d0.w = folder handle
  134. ; d1.w = file/folder index
  135. ;
  136. ;Output: nothing
  137. ;--------------------------------------------------------------
  138. filelib::hdltoindex equ filelib@0009
  139. ;--------------------------------------------------------------
  140. ;hdltoindex(file/folder handle)
  141. ;
  142. ; Returns the index of the file given its handle
  143. ; It searches in all folders.
  144. ; This function is very useful if you want to use filelib and you only
  145. ; possess the handle of a file
  146. ;
  147. ;Input:d2.w =file/folder handle to search
  148. ;
  149. ;Output: d1.w = file index
  150. ; d0.w = folder handle (=0 -> the handle wasn't found)
  151. ; NO OTHER REGISTERS DESTROYED
  152. ;--------------------------------------------------------------
  153. filelib::gettype equ filelib@000A
  154. ;--------------------------------------------------------------
  155. ;gettype(folder,file)
  156. ;
  157. ; returns the type of the file d1 in folder d0
  158. ;
  159. ;Input: d0.w = folder handle
  160. ; d1.w = file index
  161. ;
  162. ;Output: d2.w = type of the file
  163. ;
  164. ;The values for d2 are:
  165. ;
  166. ;ASM ->0
  167. ;LIB ->1
  168. ;PROG ->2
  169. ;FUNC ->3
  170. ;MAT ->4
  171. ;LIST ->5
  172. ;MACR ->6
  173. ;TEXT ->7
  174. ;STR ->8
  175. ;DATA ->9
  176. ;FIG ->10
  177. ;PIC ->11
  178. ;GDB ->12
  179. ;EXPR ->13
  180. ;OTHER ->14
  181. ;
  182. ; NO OTHER REGISTERS DESTROYED
  183. ;--------------------------------------------------------------
  184. filelib::search equ filelib@000B
  185. ;--------------------------------------------------------------
  186. ;search(file)
  187. ;
  188. ;looks in all folders if the file exists, and then returns its VAT entry adress in a0
  189. ;
  190. ;Input: a0.l: pointer to the name of the file
  191. ; d1.w : filelib::search will run d1 searches before returning, so that if different
  192. ; folders have the same file name, not only the first file will be found
  193. ;
  194. ;Output: a0.l: adress of the VAT entry of the file
  195. ; d0.w: handle of the folder of the file
  196. ;--------------------------------------------------------------
  197. filelib::createfile equ filelib@000C
  198. ;--------------------------------------------------------------
  199. ;createfile(name,folder)
  200. ;
  201. ; Creates a new file (0 bytes long)
  202. ;
  203. ;Input: a0.l = name of the file
  204. ; d0.w = folder handle
  205. ;
  206. ;Output: a0.l = VAT entry adress of the file
  207. ;
  208. ; if d2.w = 0, the file was succesfully created, else:
  209. ; 1 -> Not enough memory
  210. ; 2 -> File already exists
  211. ; 3 -> Invalid name of the file
  212. ; NO REGISTERS DESTROYED
  213. ;--------------------------------------------------------------
  214. filelib::resizefile equ filelib@000D
  215. ;--------------------------------------------------------------
  216. ;resizefile(VAT Entry adress, size)
  217. ;
  218. ; Resizes a file
  219. ;
  220. ;Input: a0.l = VAT entry adress of the file (you get it with userlib::FindSymEntry or filelib::search)
  221. ; d0.w = new size of the file
  222. ;
  223. ;Output: d0.w = size of the file
  224. ; NO REGISTERS DESTROYED
  225. ;--------------------------------------------------------------
  226. filelib::readfile equ filelib@000E
  227. ;--------------------------------------------------------------
  228. ;readfile(VAT entry adress, size, position, buffer)
  229. ;
  230. ; Reads a file
  231. ;
  232. ;Input: a0.l = VAT entry adress of the file (you get it with userlib::FindSymEntry or filelib::search)
  233. ; d0.w = nb of bytes to read (>0)
  234. ; d1.w = position of the first byte of the file to read
  235. ; a1.l = pointer to the buffer where to place all read bytes
  236. ;
  237. ;Output: d0.w = nb of bytes correctly read
  238. ; NO REGISTERS DESTROYED
  239. ;--------------------------------------------------------------
  240. filelib::writefile equ filelib@000F
  241. ;--------------------------------------------------------------
  242. ;writefile(VAT entry adress, size, position, buffer)
  243. ;
  244. ; Writes to a file, automatically tries to enlarge the file needed
  245. ;
  246. ;Input: a0.l = VAT entry adress of the file (you get it with userlib::FindSymEntry or filelib::search)
  247. ; d0.w = nb of bytes to write (>0)
  248. ; d1.w = position of the first byte of the file to write
  249. ; a1.l = pointer to the buffer containing the bytes to write
  250. ;
  251. ;Output: d0.w = nb of bytes correctly written
  252. ; NO REGISTERS DESTROYED
  253. ;--------------------------------------------------------------
  254. filelib::archive equ filelib@0010
  255. ;--------------------------------------------------------------
  256. ;archive(folder,file)
  257. ;
  258. ; Archives the file
  259. ;
  260. ;Input: d0.w = handle of the folder containing the file
  261. ; d1.w = index of the file
  262. ;
  263. ;Output:
  264. ; d2.w = result
  265. ;--------------------------------------------------------------
  266. filelib::unarchive equ filelib@0011
  267. ;--------------------------------------------------------------
  268. ;archive(folder,file)
  269. ;
  270. ; Unarchives the file
  271. ;
  272. ;Input: d0.w = hanle of the folder containing the file
  273. ; d1.w = index of the file
  274. ;
  275. ;Output:
  276. ; d2.w = result
  277. ;--------------------------------------------------------------
  278. filelib::FindSymEntry equ filelib@0012
  279. filelib::topath equ filelib@0013
  280. filelib::sendvar equ filelib@0014