1 --- Low-level and high-level filesystem manipulation library.
5 --- Check user's permission on a file.
7 -- @name nixio.fs.access
9 -- @param mode1 First Mode to check ["f", "r", "w", "x"]
10 -- @param ... More Modes to check [-"-]
13 --- Strip the directory part from a path.
15 -- @name nixio.fs.basename
16 -- @usage This function cannot fail and will never return nil.
20 --- Strip the base from a path.
22 -- @name nixio.fs.dirname
23 -- @usage This function cannot fail and will never return nil.
27 --- Return the cannonicalized absolute pathname.
29 -- @name nixio.fs.realpath
31 -- @return absolute path
33 --- Remove a file or directory.
35 -- @name nixio.fs.remove
39 --- Delete a name and - if no links are left - the associated file.
41 -- @name nixio.fs.unlink
45 --- Renames a file or directory.
47 -- @name nixio.fs.rename
48 -- @param src Source path
49 -- @param dest Destination path
50 -- @usage It is normally not possible to rename files accross fileystems.
53 --- Remove an empty directory.
55 -- @name nixio.fs.rmdir
59 --- Create a new directory.
61 -- @name nixio.fs.mkdir
63 -- @param mode File mode (optional, see chmod and umask)
64 -- @see nixio.fs.chmod
68 --- Change the file mode.
70 -- @name nixio.fs.chmod
71 -- @usage Windows only supports setting the write-protection through the
72 -- "Writable to others" bit.
73 -- @usage <strong>Notice:</strong> The mode-flag for the functions
74 -- open, mkdir, mkfifo are affected by the umask.
76 -- @param mode File mode
77 -- [decimal mode number, "[-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]"]
81 --- Iterate over the entries of a directory.
84 -- @usage The special entries "." and ".." are omitted.
86 -- @return directory iterator returning one entry per call
88 --- Create a hard link.
90 -- @name nixio.fs.link
91 -- @usage This function calls link() on POSIX and CreateHardLink() on Windows.
92 -- @param oldpath Path
93 -- @param newpath Path
96 --- Change file last access and last modification time.
98 -- @name nixio.fs.utimes
100 -- @param actime Last access timestamp (optional, default: current time)
101 -- @param mtime Last modification timestamp (optional, default: actime)
104 --- Get file status and attributes.
106 -- @name nixio.fs.stat
108 -- @param field Only return a specific field, not the whole table (optional)
109 -- @return Table containing: <ul>
110 -- <li>atime = Last access timestamp</li>
111 -- <li>blksize = Blocksize (POSIX only)</li>
112 -- <li>blocks = Blocks used (POSIX only)</li>
113 -- <li>ctime = Creation timestamp</li>
114 -- <li>dev = Device ID</li>
115 -- <li>gid = Group ID</li>
116 -- <li>ino = Inode</li>
117 -- <li>modedec = Mode converted into a decimal number</li>
118 -- <li>modestr = Mode as string as returned by `ls -l`</li>
119 -- <li>mtime = Last modification timestamp</li>
120 -- <li>nlink = Number of links</li>
121 -- <li>rdev = Device ID (if special file)</li>
122 -- <li>size = Size in bytes</li>
123 -- <li>type = ["reg", "dir", "chr", "blk", "fifo", "lnk", "sock"]</li>
124 -- <li>uid = User ID</li>
127 --- Get file status and attributes and do not resolve if target is a symlink.
129 -- @name nixio.fs.lstat
131 -- @param field Only return a specific field, not the whole table (optional)
132 -- @see nixio.fs.stat
133 -- @return Table containing attributes (see stat for a detailed description)
135 --- (POSIX) Change owner and group of a file.
137 -- @name nixio.fs.chown
139 -- @param user User ID or Username (optional)
140 -- @param group Group ID or Groupname (optional)
143 --- (POSIX) Change owner and group of a file and do not resolve
144 -- if target is a symlink.
146 -- @name nixio.fs.lchown
148 -- @param user User ID or Username (optional)
149 -- @param group Group ID or Groupname (optional)
152 --- (POSIX) Create a FIFO (named pipe).
154 -- @name nixio.fs.mkfifo
156 -- @param mode File mode (optional, see chmod and umask)
157 -- @see nixio.fs.chmod
161 --- (POSIX) Create a symbolic link.
163 -- @name nixio.fs.symlink
164 -- @param oldpath Path
165 -- @param newpath Path
168 --- (POSIX) Read the target of a symbolic link.
170 -- @name nixio.fs.readlink
172 -- @return target path
174 --- (POSIX) Find pathnames matching a pattern.
176 -- @name nixio.fs.glob
177 -- @param pattern Pattern
178 -- @return path iterator
179 -- @return number of matches
181 --- (POSIX) Get filesystem statistics.
183 -- @name nixio.fs.statvfs
184 -- @param path Path to any file within the filesystem.
185 -- @return Table containing: <ul>
186 -- <li>bavail = available blocks</li>
187 -- <li>bfree = free blocks</li>
188 -- <li>blocks = number of fragments</li>
189 -- <li>frsize = fragment size</li>
190 -- <li>favail = available inodes</li>
191 -- <li>ffree = free inodes</li>
192 -- <li>files = inodes</li>
193 -- <li>flag = flags</li>
194 -- <li>fsid = filesystem ID</li>
195 -- <li>namemax = maximum filename length</li>
198 --- Read the contents of a file into a buffer.
200 -- @name nixio.fs.readfile
202 -- @param limit Maximum bytes to read (optional)
203 -- @return file contents
205 --- Write a buffer into a file truncating the file first.
207 -- @name nixio.fs.writefile
209 -- @param data Data to write
212 --- Copy data between files.
214 -- @name nixio.fs.datacopy
215 -- @param src Source file path
216 -- @param dest Destination file path
217 -- @param limit Maximum bytes to copy (optional)
220 --- Copy a file, directory or symlink non-recursively preserving file mode,
221 -- timestamps, owner and group.
223 -- @name nixio.fs.copy
224 -- @usage The destination must always be a full destination path e.g. do not
225 -- omit the basename even if source and destination basename are equal.
226 -- @param src Source path
227 -- @param dest Destination path
230 --- Rename a file, directory or symlink non-recursively across filesystems.
232 -- @name nixio.fs.move
233 -- @usage The destination must always be a full destination path e.g. do not
234 -- omit the basename even if source and destination basename are equal.
235 -- @param src Source path
236 -- @param dest Destination path
239 --- Create a directory and all needed parent directories recursively.
241 -- @name nixio.fs.mkdirr
242 -- @param dest Destination path
243 -- @param mode File mode (optional, see chmod and umask)
244 -- @see nixio.fs.chmod
248 --- Rename a file, directory or symlink recursively across filesystems.
250 -- @name nixio.fs.mover
251 -- @usage The destination must always be a full destination path e.g. do not
252 -- omit the basename even if source and destination basename are equal.
253 -- @param src Source path
254 -- @param dest Destination path
257 --- Copy a file, directory or symlink recursively preserving file mode,
258 -- timestamps, owner and group.
260 -- @name nixio.fs.copyr
261 -- @usage The destination must always be a full destination path e.g. do not
262 -- omit the basename even if source and destination basename are equal.
263 -- @param src Source path
264 -- @param dest Destination path