home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Ti / Magazine / Tests / DOORSOSD.ZIP / filelib.h < prev    next >
Encoding:
Text File  |  1999-12-22  |  8.8 KB  |  303 lines

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