<ahref=#introductionclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><p>The fs module provides filesystem functions to Hilbish. While Lua’s standard
library has some I/O functions, they’re missing a lot of the basics. The <code>fs</code>
library offers more functions and will work on any operating system Hilbish does.</p><h3id=functionsclass=heading>Functions
<ahref=#functionsclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><ahref=#abs>abs(path) -> string</a></td><td>Returns an absolute version of the <code>path</code>.</td></tr><tr><td><ahref=#basename>basename(path) -> string</a></td><td>Returns the “basename,” or the last part of the provided <code>path</code>. If path is empty,</td></tr><tr><td><ahref=#cd>cd(dir)</a></td><td>Changes Hilbish’s directory to <code>dir</code>.</td></tr><tr><td><ahref=#dir>dir(path) -> string</a></td><td>Returns the directory part of <code>path</code>. If a file path like</td></tr><tr><td><ahref=#glob>glob(pattern) -> matches (table)</a></td><td>Match all files based on the provided <code>pattern</code>.</td></tr><tr><td><ahref=#join>join(…path) -> string</a></td><td>Takes any list of paths and joins them based on the operating system’s path separator.</td></tr><tr><td><ahref=#mkdir>mkdir(name, recursive)</a></td><td>Creates a new directory with the provided <code>name</code>.</td></tr><tr><td><ahref=#readdir>readdir(path) -> table[string]</a></td><td>Returns a list of all files and directories in the provided path.</td></tr><tr><td><ahref=#stat>stat(path) -> {}</a></td><td>Returns the information about a given <code>path</code>.</td></tr></tbody></table><h3id=static-module-fieldsclass=heading>Static module fields
<ahref=#absclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns an absolute version of the <code>path</code>.<br>This can be used to resolve short paths like <code>..</code> to <code>/home/user</code>.</p><h5id=parametersclass=heading>Parameters
<ahref=#basenameclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns the “basename,” or the last part of the provided <code>path</code>. If path is empty,<br><code>.</code> will be returned.</p><h5id=parameters-1class=heading>Parameters
<ahref=#parameters-1class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>path</code></strong><br>Path to get the base name of.</p></div><hr><divid=cd><h4class=heading>fs.cd(dir)
<ahref=#cdclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Changes Hilbish’s directory to <code>dir</code>.</p><h5id=parameters-2class=heading>Parameters
<ahref=#parameters-2class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>dir</code></strong><br>Path to change directory to.</p></div><hr><divid=dir><h4class=heading>fs.dir(path) -> string
<ahref=#dirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns the directory part of <code>path</code>. If a file path like<br><code>~/Documents/doc.txt</code> then this function will return <code>~/Documents</code>.</p><h5id=parameters-3class=heading>Parameters
<ahref=#parameters-3class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>path</code></strong><br>Path to get the directory for.</p></div><hr><divid=glob><h4class=heading>fs.glob(pattern) -> matches (table)
<ahref=#globclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Match all files based on the provided <code>pattern</code>.<br>For the syntax’ refer to Go’s filepath.Match function: <ahref=https://pkg.go.dev/path/filepath#Matchtarget=_blankrel=noopener>https://pkg.go.dev/path/filepath#Match</a></p><h5id=parameters-4class=heading>Parameters
<ahref=#parameters-4class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>pattern</code></strong><br>Pattern to compare files with.</p><h5id=exampleclass=heading>Example
<ahref=#joinclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Takes any list of paths and joins them based on the operating system’s path separator.</p><h5id=parameters-5class=heading>Parameters
<ahref=#parameters-5class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>path</code></strong> (This type is variadic. You can pass an infinite amount of parameters with this type.)<br>Paths to join together</p><h5id=example-1class=heading>Example
<ahref=#example-1class=heading-link><iclass="fas fa-paperclip"></i></a></h5><divclass=highlight><pretabindex=0class=chroma><codeclass=language-luadata-lang=lua><spanclass=line><spanclass=ln>1</span><spanclass=cl><spanclass=c1>-- This prints the directory for Hilbish's config!</span>
<ahref=#mkdirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Creates a new directory with the provided <code>name</code>.<br>With <code>recursive</code>, mkdir will create parent directories.<br>– This will create the directory foo, then create the directory bar in the<br>– foo directory. If recursive is false in this case, it will fail.<br>fs.mkdir(’./foo/bar’, true)</p><h5id=parameters-6class=heading>Parameters
<ahref=#parameters-6class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>Name of the directory</p><p><code>boolean</code><strong><code>recursive</code></strong><br>Whether to create parent directories for the provided name</p><h5id=example-2class=heading>Example
<ahref=#readdirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns a list of all files and directories in the provided path.</p><h5id=parameters-7class=heading>Parameters
<ahref=#statclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns the information about a given <code>path</code>.<br>The returned table contains the following values:<br>name (string) - Name of the path<br>size (number) - Size of the path in bytes<br>mode (string) - Unix permission mode in an octal format string (with leading 0)<br>isDir (boolean) - If the path is a directory</p><h5id=parameters-8class=heading>Parameters