1
0

nixio.fs.html 21 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html>
  4. <head>
  5. <title>Reference</title>
  6. <link rel="stylesheet" href="../luadoc.css" type="text/css" />
  7. <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
  8. </head>
  9. <body>
  10. <div id="container">
  11. <div id="product">
  12. <div id="product_logo"></div>
  13. <div id="product_name"><big><b></b></big></div>
  14. <div id="product_description"></div>
  15. </div> <!-- id="product" -->
  16. <div id="main">
  17. <div id="navigation">
  18. <h1>LuaDoc</h1>
  19. <ul>
  20. <li><a href="../index.html">Index</a></li>
  21. </ul>
  22. <!-- Module list -->
  23. <h1>Modules</h1>
  24. <ul>
  25. <li>
  26. <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
  27. </li>
  28. <li>
  29. <a href="../modules/luci.http.html">luci.http</a>
  30. </li>
  31. <li>
  32. <a href="../modules/luci.http.protocol.html">luci.http.protocol</a>
  33. </li>
  34. <li>
  35. <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
  36. </li>
  37. <li>
  38. <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
  39. </li>
  40. <li>
  41. <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
  42. </li>
  43. <li>
  44. <a href="../modules/luci.i18n.html">luci.i18n</a>
  45. </li>
  46. <li>
  47. <a href="../modules/luci.ip.html">luci.ip</a>
  48. </li>
  49. <li>
  50. <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
  51. </li>
  52. <li>
  53. <a href="../modules/luci.json.html">luci.json</a>
  54. </li>
  55. <li>
  56. <a href="../modules/luci.jsonc.html">luci.jsonc</a>
  57. </li>
  58. <li>
  59. <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
  60. </li>
  61. <li>
  62. <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
  63. </li>
  64. <li>
  65. <a href="../modules/luci.model.uci.html">luci.model.uci</a>
  66. </li>
  67. <li>
  68. <a href="../modules/luci.rpcc.html">luci.rpcc</a>
  69. </li>
  70. <li>
  71. <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
  72. </li>
  73. <li>
  74. <a href="../modules/luci.sys.html">luci.sys</a>
  75. </li>
  76. <li>
  77. <a href="../modules/luci.sys.init.html">luci.sys.init</a>
  78. </li>
  79. <li>
  80. <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
  81. </li>
  82. <li>
  83. <a href="../modules/luci.sys.net.html">luci.sys.net</a>
  84. </li>
  85. <li>
  86. <a href="../modules/luci.sys.process.html">luci.sys.process</a>
  87. </li>
  88. <li>
  89. <a href="../modules/luci.sys.user.html">luci.sys.user</a>
  90. </li>
  91. <li>
  92. <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
  93. </li>
  94. <li>
  95. <a href="../modules/luci.util.html">luci.util</a>
  96. </li>
  97. <li>
  98. <a href="../modules/nixio.html">nixio</a>
  99. </li>
  100. <li>
  101. <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
  102. </li>
  103. <li>
  104. <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
  105. </li>
  106. <li>
  107. <a href="../modules/nixio.File.html">nixio.File</a>
  108. </li>
  109. <li>
  110. <a href="../modules/nixio.README.html">nixio.README</a>
  111. </li>
  112. <li>
  113. <a href="../modules/nixio.Socket.html">nixio.Socket</a>
  114. </li>
  115. <li>
  116. <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
  117. </li>
  118. <li>
  119. <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
  120. </li>
  121. <li>
  122. <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
  123. </li>
  124. <li>
  125. <a href="../modules/nixio.bin.html">nixio.bin</a>
  126. </li>
  127. <li>
  128. <a href="../modules/nixio.bit.html">nixio.bit</a>
  129. </li>
  130. <li>
  131. <a href="../modules/nixio.crypto.html">nixio.crypto</a>
  132. </li>
  133. <li><strong>nixio.fs</strong></li>
  134. </ul>
  135. <!-- File list -->
  136. </div><!-- id="navigation" -->
  137. <div id="content">
  138. <h1>Class <code>nixio.fs</code></h1>
  139. <p>
  140. Low-level and high-level filesystem manipulation library.</p>
  141. <h2>Functions</h2>
  142. <table class="function_list">
  143. <tr>
  144. <td class="name" nowrap><a href="#nixio.fs.access">access</a>&nbsp;(path, mode1, ...)</td>
  145. <td class="summary">
  146. Check user's permission on a file.</td>
  147. </tr>
  148. <tr>
  149. <td class="name" nowrap><a href="#nixio.fs.basename">basename</a>&nbsp;(path)</td>
  150. <td class="summary">
  151. Strip the directory part from a path.</td>
  152. </tr>
  153. <tr>
  154. <td class="name" nowrap><a href="#nixio.fs.chmod">chmod</a>&nbsp;(path, mode)</td>
  155. <td class="summary">
  156. Change the file mode.</td>
  157. </tr>
  158. <tr>
  159. <td class="name" nowrap><a href="#nixio.fs.chown">chown</a>&nbsp;(path, user, group)</td>
  160. <td class="summary">
  161. (POSIX) Change owner and group of a file.</td>
  162. </tr>
  163. <tr>
  164. <td class="name" nowrap><a href="#nixio.fs.copy">copy</a>&nbsp;(src, dest)</td>
  165. <td class="summary">
  166. Copy a file, directory or symlink non-recursively preserving file mode,
  167. timestamps, owner and group.</td>
  168. </tr>
  169. <tr>
  170. <td class="name" nowrap><a href="#nixio.fs.copyr">copyr</a>&nbsp;(src, dest)</td>
  171. <td class="summary">
  172. Copy a file, directory or symlink recursively preserving file mode,
  173. timestamps, owner and group.</td>
  174. </tr>
  175. <tr>
  176. <td class="name" nowrap><a href="#nixio.fs.datacopy">datacopy</a>&nbsp;(src, dest, limit)</td>
  177. <td class="summary">
  178. Copy data between files.</td>
  179. </tr>
  180. <tr>
  181. <td class="name" nowrap><a href="#nixio.fs.dir">dir</a>&nbsp;(path)</td>
  182. <td class="summary">
  183. Iterate over the entries of a directory.</td>
  184. </tr>
  185. <tr>
  186. <td class="name" nowrap><a href="#nixio.fs.dirname">dirname</a>&nbsp;(path)</td>
  187. <td class="summary">
  188. Strip the base from a path.</td>
  189. </tr>
  190. <tr>
  191. <td class="name" nowrap><a href="#nixio.fs.glob">glob</a>&nbsp;(pattern)</td>
  192. <td class="summary">
  193. (POSIX) Find pathnames matching a pattern.</td>
  194. </tr>
  195. <tr>
  196. <td class="name" nowrap><a href="#nixio.fs.lchown">lchown</a>&nbsp;(path, user, group)</td>
  197. <td class="summary">
  198. (POSIX) Change owner and group of a file and do not resolve
  199. if target is a symlink.</td>
  200. </tr>
  201. <tr>
  202. <td class="name" nowrap><a href="#nixio.fs.link">link</a>&nbsp;(oldpath, newpath)</td>
  203. <td class="summary">
  204. Create a hard link.</td>
  205. </tr>
  206. <tr>
  207. <td class="name" nowrap><a href="#nixio.fs.lstat">lstat</a>&nbsp;(path, field)</td>
  208. <td class="summary">
  209. Get file status and attributes and do not resolve if target is a symlink.</td>
  210. </tr>
  211. <tr>
  212. <td class="name" nowrap><a href="#nixio.fs.mkdir">mkdir</a>&nbsp;(path, mode)</td>
  213. <td class="summary">
  214. Create a new directory.</td>
  215. </tr>
  216. <tr>
  217. <td class="name" nowrap><a href="#nixio.fs.mkdirr">mkdirr</a>&nbsp;(dest, mode)</td>
  218. <td class="summary">
  219. Create a directory and all needed parent directories recursively.</td>
  220. </tr>
  221. <tr>
  222. <td class="name" nowrap><a href="#nixio.fs.mkfifo">mkfifo</a>&nbsp;(path, mode)</td>
  223. <td class="summary">
  224. (POSIX) Create a FIFO (named pipe).</td>
  225. </tr>
  226. <tr>
  227. <td class="name" nowrap><a href="#nixio.fs.move">move</a>&nbsp;(src, dest)</td>
  228. <td class="summary">
  229. Rename a file, directory or symlink non-recursively across filesystems.</td>
  230. </tr>
  231. <tr>
  232. <td class="name" nowrap><a href="#nixio.fs.mover">mover</a>&nbsp;(src, dest)</td>
  233. <td class="summary">
  234. Rename a file, directory or symlink recursively across filesystems.</td>
  235. </tr>
  236. <tr>
  237. <td class="name" nowrap><a href="#nixio.fs.readfile">readfile</a>&nbsp;(path, limit)</td>
  238. <td class="summary">
  239. Read the contents of a file into a buffer.</td>
  240. </tr>
  241. <tr>
  242. <td class="name" nowrap><a href="#nixio.fs.readlink">readlink</a>&nbsp;(path)</td>
  243. <td class="summary">
  244. (POSIX) Read the target of a symbolic link.</td>
  245. </tr>
  246. <tr>
  247. <td class="name" nowrap><a href="#nixio.fs.realpath">realpath</a>&nbsp;(path)</td>
  248. <td class="summary">
  249. Return the cannonicalized absolute pathname.</td>
  250. </tr>
  251. <tr>
  252. <td class="name" nowrap><a href="#nixio.fs.remove">remove</a>&nbsp;(path)</td>
  253. <td class="summary">
  254. Remove a file or directory.</td>
  255. </tr>
  256. <tr>
  257. <td class="name" nowrap><a href="#nixio.fs.rename">rename</a>&nbsp;(src, dest)</td>
  258. <td class="summary">
  259. Renames a file or directory.</td>
  260. </tr>
  261. <tr>
  262. <td class="name" nowrap><a href="#nixio.fs.rmdir">rmdir</a>&nbsp;(path)</td>
  263. <td class="summary">
  264. Remove an empty directory.</td>
  265. </tr>
  266. <tr>
  267. <td class="name" nowrap><a href="#nixio.fs.stat">stat</a>&nbsp;(path, field)</td>
  268. <td class="summary">
  269. Get file status and attributes.</td>
  270. </tr>
  271. <tr>
  272. <td class="name" nowrap><a href="#nixio.fs.statvfs">statvfs</a>&nbsp;(path)</td>
  273. <td class="summary">
  274. (POSIX) Get filesystem statistics.</td>
  275. </tr>
  276. <tr>
  277. <td class="name" nowrap><a href="#nixio.fs.symlink">symlink</a>&nbsp;(oldpath, newpath)</td>
  278. <td class="summary">
  279. (POSIX) Create a symbolic link.</td>
  280. </tr>
  281. <tr>
  282. <td class="name" nowrap><a href="#nixio.fs.unlink">unlink</a>&nbsp;(path)</td>
  283. <td class="summary">
  284. Delete a name and - if no links are left - the associated file.</td>
  285. </tr>
  286. <tr>
  287. <td class="name" nowrap><a href="#nixio.fs.utimes">utimes</a>&nbsp;(path, actime, mtime)</td>
  288. <td class="summary">
  289. Change file last access and last modification time.</td>
  290. </tr>
  291. <tr>
  292. <td class="name" nowrap><a href="#nixio.fs.writefile">writefile</a>&nbsp;(path, data)</td>
  293. <td class="summary">
  294. Write a buffer into a file truncating the file first.</td>
  295. </tr>
  296. </table>
  297. <br/>
  298. <br/>
  299. <h2><a name="functions"></a>Functions</h2>
  300. <dl class="function">
  301. <dt><a name="nixio.fs.access"></a><strong>access</strong>&nbsp;(path, mode1, ...)</dt>
  302. <dd>
  303. Check user's permission on a file.
  304. <h3>Parameters</h3>
  305. <ul>
  306. <li>
  307. path: Path
  308. </li>
  309. <li>
  310. mode1: First Mode to check ["f", "r", "w", "x"]
  311. </li>
  312. <li>
  313. ...: More Modes to check [-"-]
  314. </li>
  315. </ul>
  316. <h3>Return value:</h3>
  317. true
  318. </dd>
  319. <dt><a name="nixio.fs.basename"></a><strong>basename</strong>&nbsp;(path)</dt>
  320. <dd>
  321. Strip the directory part from a path.
  322. <h3>Parameters</h3>
  323. <ul>
  324. <li>
  325. path: Path
  326. </li>
  327. </ul>
  328. <h3>Usage:</h3>
  329. This function cannot fail and will never return nil.
  330. <h3>Return value:</h3>
  331. basename
  332. </dd>
  333. <dt><a name="nixio.fs.chmod"></a><strong>chmod</strong>&nbsp;(path, mode)</dt>
  334. <dd>
  335. Change the file mode.
  336. <h3>Parameters</h3>
  337. <ul>
  338. <li>
  339. path: Path
  340. </li>
  341. <li>
  342. mode: File mode
  343. [decimal mode number, "[-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]"]
  344. </li>
  345. </ul>
  346. <h3>Usage</h3>
  347. <ul>
  348. <li>Windows only supports setting the write-protection through the
  349. "Writable to others" bit.
  350. <li><strong>Notice:</strong> The mode-flag for the functions
  351. open, mkdir, mkfifo are affected by the umask.
  352. </ul>
  353. <h3>Return value:</h3>
  354. true
  355. <h3>See also:</h3>
  356. <ul>
  357. <li><a href="">
  358. umask
  359. </a>
  360. </ul>
  361. </dd>
  362. <dt><a name="nixio.fs.chown"></a><strong>chown</strong>&nbsp;(path, user, group)</dt>
  363. <dd>
  364. (POSIX) Change owner and group of a file.
  365. <h3>Parameters</h3>
  366. <ul>
  367. <li>
  368. path: Path
  369. </li>
  370. <li>
  371. user: User ID or Username (optional)
  372. </li>
  373. <li>
  374. group: Group ID or Groupname (optional)
  375. </li>
  376. </ul>
  377. <h3>Return value:</h3>
  378. true
  379. </dd>
  380. <dt><a name="nixio.fs.copy"></a><strong>copy</strong>&nbsp;(src, dest)</dt>
  381. <dd>
  382. Copy a file, directory or symlink non-recursively preserving file mode,
  383. timestamps, owner and group.
  384. <h3>Parameters</h3>
  385. <ul>
  386. <li>
  387. src: Source path
  388. </li>
  389. <li>
  390. dest: Destination path
  391. </li>
  392. </ul>
  393. <h3>Usage:</h3>
  394. The destination must always be a full destination path e.g. do not
  395. omit the basename even if source and destination basename are equal.
  396. <h3>Return value:</h3>
  397. true
  398. </dd>
  399. <dt><a name="nixio.fs.copyr"></a><strong>copyr</strong>&nbsp;(src, dest)</dt>
  400. <dd>
  401. Copy a file, directory or symlink recursively preserving file mode,
  402. timestamps, owner and group.
  403. <h3>Parameters</h3>
  404. <ul>
  405. <li>
  406. src: Source path
  407. </li>
  408. <li>
  409. dest: Destination path
  410. </li>
  411. </ul>
  412. <h3>Usage:</h3>
  413. The destination must always be a full destination path e.g. do not
  414. omit the basename even if source and destination basename are equal.
  415. <h3>Return value:</h3>
  416. true
  417. </dd>
  418. <dt><a name="nixio.fs.datacopy"></a><strong>datacopy</strong>&nbsp;(src, dest, limit)</dt>
  419. <dd>
  420. Copy data between files.
  421. <h3>Parameters</h3>
  422. <ul>
  423. <li>
  424. src: Source file path
  425. </li>
  426. <li>
  427. dest: Destination file path
  428. </li>
  429. <li>
  430. limit: Maximum bytes to copy (optional)
  431. </li>
  432. </ul>
  433. <h3>Return value:</h3>
  434. true
  435. </dd>
  436. <dt><a name="nixio.fs.dir"></a><strong>dir</strong>&nbsp;(path)</dt>
  437. <dd>
  438. Iterate over the entries of a directory.
  439. <h3>Parameters</h3>
  440. <ul>
  441. <li>
  442. path: Path
  443. </li>
  444. </ul>
  445. <h3>Usage:</h3>
  446. The special entries "." and ".." are omitted.
  447. <h3>Return value:</h3>
  448. directory iterator returning one entry per call
  449. </dd>
  450. <dt><a name="nixio.fs.dirname"></a><strong>dirname</strong>&nbsp;(path)</dt>
  451. <dd>
  452. Strip the base from a path.
  453. <h3>Parameters</h3>
  454. <ul>
  455. <li>
  456. path: Path
  457. </li>
  458. </ul>
  459. <h3>Usage:</h3>
  460. This function cannot fail and will never return nil.
  461. <h3>Return value:</h3>
  462. dirname
  463. </dd>
  464. <dt><a name="nixio.fs.glob"></a><strong>glob</strong>&nbsp;(pattern)</dt>
  465. <dd>
  466. (POSIX) Find pathnames matching a pattern.
  467. <h3>Parameters</h3>
  468. <ul>
  469. <li>
  470. pattern: Pattern
  471. </li>
  472. </ul>
  473. <h3>Return values:</h3>
  474. <ol>
  475. <li>path iterator
  476. <li>number of matches
  477. </ol>
  478. </dd>
  479. <dt><a name="nixio.fs.lchown"></a><strong>lchown</strong>&nbsp;(path, user, group)</dt>
  480. <dd>
  481. (POSIX) Change owner and group of a file and do not resolve
  482. if target is a symlink.
  483. <h3>Parameters</h3>
  484. <ul>
  485. <li>
  486. path: Path
  487. </li>
  488. <li>
  489. user: User ID or Username (optional)
  490. </li>
  491. <li>
  492. group: Group ID or Groupname (optional)
  493. </li>
  494. </ul>
  495. <h3>Return value:</h3>
  496. true
  497. </dd>
  498. <dt><a name="nixio.fs.link"></a><strong>link</strong>&nbsp;(oldpath, newpath)</dt>
  499. <dd>
  500. Create a hard link.
  501. <h3>Parameters</h3>
  502. <ul>
  503. <li>
  504. oldpath: Path
  505. </li>
  506. <li>
  507. newpath: Path
  508. </li>
  509. </ul>
  510. <h3>Usage:</h3>
  511. This function calls link() on POSIX and CreateHardLink() on Windows.
  512. <h3>Return value:</h3>
  513. true
  514. </dd>
  515. <dt><a name="nixio.fs.lstat"></a><strong>lstat</strong>&nbsp;(path, field)</dt>
  516. <dd>
  517. Get file status and attributes and do not resolve if target is a symlink.
  518. <h3>Parameters</h3>
  519. <ul>
  520. <li>
  521. path: Path
  522. </li>
  523. <li>
  524. field: Only return a specific field, not the whole table (optional)
  525. </li>
  526. </ul>
  527. <h3>Return value:</h3>
  528. Table containing attributes (see stat for a detailed description)
  529. <h3>See also:</h3>
  530. <ul>
  531. <li><a href="#nixio.fs.stat">
  532. stat
  533. </a>
  534. </ul>
  535. </dd>
  536. <dt><a name="nixio.fs.mkdir"></a><strong>mkdir</strong>&nbsp;(path, mode)</dt>
  537. <dd>
  538. Create a new directory.
  539. <h3>Parameters</h3>
  540. <ul>
  541. <li>
  542. path: Path
  543. </li>
  544. <li>
  545. mode: File mode (optional, see chmod and umask)
  546. </li>
  547. </ul>
  548. <h3>Return value:</h3>
  549. true
  550. <h3>See also:</h3>
  551. <ul>
  552. <li><a href="#nixio.fs.chmod">
  553. chmod
  554. </a>
  555. <li><a href="">
  556. umask
  557. </a>
  558. </ul>
  559. </dd>
  560. <dt><a name="nixio.fs.mkdirr"></a><strong>mkdirr</strong>&nbsp;(dest, mode)</dt>
  561. <dd>
  562. Create a directory and all needed parent directories recursively.
  563. <h3>Parameters</h3>
  564. <ul>
  565. <li>
  566. dest: Destination path
  567. </li>
  568. <li>
  569. mode: File mode (optional, see chmod and umask)
  570. </li>
  571. </ul>
  572. <h3>Return value:</h3>
  573. true
  574. <h3>See also:</h3>
  575. <ul>
  576. <li><a href="#nixio.fs.chmod">
  577. chmod
  578. </a>
  579. <li><a href="">
  580. umask
  581. </a>
  582. </ul>
  583. </dd>
  584. <dt><a name="nixio.fs.mkfifo"></a><strong>mkfifo</strong>&nbsp;(path, mode)</dt>
  585. <dd>
  586. (POSIX) Create a FIFO (named pipe).
  587. <h3>Parameters</h3>
  588. <ul>
  589. <li>
  590. path: Path
  591. </li>
  592. <li>
  593. mode: File mode (optional, see chmod and umask)
  594. </li>
  595. </ul>
  596. <h3>Return value:</h3>
  597. true
  598. <h3>See also:</h3>
  599. <ul>
  600. <li><a href="#nixio.fs.chmod">
  601. chmod
  602. </a>
  603. <li><a href="">
  604. umask
  605. </a>
  606. </ul>
  607. </dd>
  608. <dt><a name="nixio.fs.move"></a><strong>move</strong>&nbsp;(src, dest)</dt>
  609. <dd>
  610. Rename a file, directory or symlink non-recursively across filesystems.
  611. <h3>Parameters</h3>
  612. <ul>
  613. <li>
  614. src: Source path
  615. </li>
  616. <li>
  617. dest: Destination path
  618. </li>
  619. </ul>
  620. <h3>Usage:</h3>
  621. The destination must always be a full destination path e.g. do not
  622. omit the basename even if source and destination basename are equal.
  623. <h3>Return value:</h3>
  624. true
  625. </dd>
  626. <dt><a name="nixio.fs.mover"></a><strong>mover</strong>&nbsp;(src, dest)</dt>
  627. <dd>
  628. Rename a file, directory or symlink recursively across filesystems.
  629. <h3>Parameters</h3>
  630. <ul>
  631. <li>
  632. src: Source path
  633. </li>
  634. <li>
  635. dest: Destination path
  636. </li>
  637. </ul>
  638. <h3>Usage:</h3>
  639. The destination must always be a full destination path e.g. do not
  640. omit the basename even if source and destination basename are equal.
  641. <h3>Return value:</h3>
  642. true
  643. </dd>
  644. <dt><a name="nixio.fs.readfile"></a><strong>readfile</strong>&nbsp;(path, limit)</dt>
  645. <dd>
  646. Read the contents of a file into a buffer.
  647. <h3>Parameters</h3>
  648. <ul>
  649. <li>
  650. path: Path
  651. </li>
  652. <li>
  653. limit: Maximum bytes to read (optional)
  654. </li>
  655. </ul>
  656. <h3>Return value:</h3>
  657. file contents
  658. </dd>
  659. <dt><a name="nixio.fs.readlink"></a><strong>readlink</strong>&nbsp;(path)</dt>
  660. <dd>
  661. (POSIX) Read the target of a symbolic link.
  662. <h3>Parameters</h3>
  663. <ul>
  664. <li>
  665. path: Path
  666. </li>
  667. </ul>
  668. <h3>Return value:</h3>
  669. target path
  670. </dd>
  671. <dt><a name="nixio.fs.realpath"></a><strong>realpath</strong>&nbsp;(path)</dt>
  672. <dd>
  673. Return the cannonicalized absolute pathname.
  674. <h3>Parameters</h3>
  675. <ul>
  676. <li>
  677. path: Path
  678. </li>
  679. </ul>
  680. <h3>Return value:</h3>
  681. absolute path
  682. </dd>
  683. <dt><a name="nixio.fs.remove"></a><strong>remove</strong>&nbsp;(path)</dt>
  684. <dd>
  685. Remove a file or directory.
  686. <h3>Parameters</h3>
  687. <ul>
  688. <li>
  689. path: Path
  690. </li>
  691. </ul>
  692. <h3>Return value:</h3>
  693. true
  694. </dd>
  695. <dt><a name="nixio.fs.rename"></a><strong>rename</strong>&nbsp;(src, dest)</dt>
  696. <dd>
  697. Renames a file or directory.
  698. <h3>Parameters</h3>
  699. <ul>
  700. <li>
  701. src: Source path
  702. </li>
  703. <li>
  704. dest: Destination path
  705. </li>
  706. </ul>
  707. <h3>Usage:</h3>
  708. It is normally not possible to rename files across fileystems.
  709. <h3>Return value:</h3>
  710. true
  711. </dd>
  712. <dt><a name="nixio.fs.rmdir"></a><strong>rmdir</strong>&nbsp;(path)</dt>
  713. <dd>
  714. Remove an empty directory.
  715. <h3>Parameters</h3>
  716. <ul>
  717. <li>
  718. path: Path
  719. </li>
  720. </ul>
  721. <h3>Return value:</h3>
  722. true
  723. </dd>
  724. <dt><a name="nixio.fs.stat"></a><strong>stat</strong>&nbsp;(path, field)</dt>
  725. <dd>
  726. Get file status and attributes.
  727. <h3>Parameters</h3>
  728. <ul>
  729. <li>
  730. path: Path
  731. </li>
  732. <li>
  733. field: Only return a specific field, not the whole table (optional)
  734. </li>
  735. </ul>
  736. <h3>Return value:</h3>
  737. Table containing: <ul>
  738. <li>atime = Last access timestamp</li>
  739. <li>blksize = Blocksize (POSIX only)</li>
  740. <li>blocks = Blocks used (POSIX only)</li>
  741. <li>ctime = Creation timestamp</li>
  742. <li>dev = Device ID</li>
  743. <li>gid = Group ID</li>
  744. <li>ino = Inode</li>
  745. <li>modedec = Mode converted into a decimal number</li>
  746. <li>modestr = Mode as string as returned by <code>ls -l</code></li>
  747. <li>mtime = Last modification timestamp</li>
  748. <li>nlink = Number of links</li>
  749. <li>rdev = Device ID (if special file)</li>
  750. <li>size = Size in bytes</li>
  751. <li>type = ["reg", "dir", "chr", "blk", "fifo", "lnk", "sock"]</li>
  752. <li>uid = User ID</li>
  753. </ul>
  754. </dd>
  755. <dt><a name="nixio.fs.statvfs"></a><strong>statvfs</strong>&nbsp;(path)</dt>
  756. <dd>
  757. (POSIX) Get filesystem statistics.
  758. <h3>Parameters</h3>
  759. <ul>
  760. <li>
  761. path: Path to any file within the filesystem.
  762. </li>
  763. </ul>
  764. <h3>Return value:</h3>
  765. Table containing: <ul>
  766. <li>bavail = available blocks</li>
  767. <li>bfree = free blocks</li>
  768. <li>blocks = number of fragments</li>
  769. <li>frsize = fragment size</li>
  770. <li>favail = available inodes</li>
  771. <li>ffree = free inodes</li>
  772. <li>files = inodes</li>
  773. <li>flag = flags</li>
  774. <li>fsid = filesystem ID</li>
  775. <li>namemax = maximum filename length</li>
  776. </ul>
  777. </dd>
  778. <dt><a name="nixio.fs.symlink"></a><strong>symlink</strong>&nbsp;(oldpath, newpath)</dt>
  779. <dd>
  780. (POSIX) Create a symbolic link.
  781. <h3>Parameters</h3>
  782. <ul>
  783. <li>
  784. oldpath: Path
  785. </li>
  786. <li>
  787. newpath: Path
  788. </li>
  789. </ul>
  790. <h3>Return value:</h3>
  791. true
  792. </dd>
  793. <dt><a name="nixio.fs.unlink"></a><strong>unlink</strong>&nbsp;(path)</dt>
  794. <dd>
  795. Delete a name and - if no links are left - the associated file.
  796. <h3>Parameters</h3>
  797. <ul>
  798. <li>
  799. path: Path
  800. </li>
  801. </ul>
  802. <h3>Return value:</h3>
  803. true
  804. </dd>
  805. <dt><a name="nixio.fs.utimes"></a><strong>utimes</strong>&nbsp;(path, actime, mtime)</dt>
  806. <dd>
  807. Change file last access and last modification time.
  808. <h3>Parameters</h3>
  809. <ul>
  810. <li>
  811. path: Path
  812. </li>
  813. <li>
  814. actime: Last access timestamp (optional, default: current time)
  815. </li>
  816. <li>
  817. mtime: Last modification timestamp (optional, default: actime)
  818. </li>
  819. </ul>
  820. <h3>Return value:</h3>
  821. true
  822. </dd>
  823. <dt><a name="nixio.fs.writefile"></a><strong>writefile</strong>&nbsp;(path, data)</dt>
  824. <dd>
  825. Write a buffer into a file truncating the file first.
  826. <h3>Parameters</h3>
  827. <ul>
  828. <li>
  829. path: Path
  830. </li>
  831. <li>
  832. data: Data to write
  833. </li>
  834. </ul>
  835. <h3>Return value:</h3>
  836. true
  837. </dd>
  838. </dl>
  839. </div> <!-- id="content" -->
  840. </div> <!-- id="main" -->
  841. <div id="about">
  842. <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
  843. </div> <!-- id="about" -->
  844. </div> <!-- id="container" -->
  845. </body>
  846. </html>