Adds stat updates to reame and fixes path output for stat to take directories into account
This commit is contained in:
parent
b3c9f5eee1
commit
019c076dba
14
README.md
14
README.md
@ -288,7 +288,19 @@ Not implemented, but on my radar:
|
||||
<li><code>(file-open-write [filepath: string])</code>: <code>IOHandle</code></li>
|
||||
<li><code>(file-append-to [filepath: string] [string...])</code>: <code>()</code></li>
|
||||
<li><code>(file-name [IOHandle: file])</code>: <code>string</code></li>
|
||||
<li><code>(file-stat [filepath: string])</code>: <code>assoc list</code> The associative list will have the following keys: <code>name</code>, <code>size</code>, <code>mode</code>, <code>mod-time</code>, <code>is-dir?</code>. <code>mode</code> will be in decimal as a number and can be converted to an octal string with <code>number->string</code>. <code>size</code> is in bytes.</li>
|
||||
<li><code>(file-stat [filepath: string])</code>: <code>assoc list</code>
|
||||
<p>The associative list will have the following keys: </p>
|
||||
<ul>
|
||||
<li><code>name</code></li>
|
||||
<li><code>size</code></li>
|
||||
<li><code>mode</code></li>
|
||||
<li><code>mod-time</code></li>
|
||||
<li><code>is-dir?</code></li>
|
||||
<li><code>is-symlink?</code></li>
|
||||
<li><code>path</code></li>
|
||||
</ul>
|
||||
<p><code>mode</code> will be in decimal as a number and can be converted to an octal string with <code>number->string</code>. <code>size</code> is in bytes. <code>path</code> will be an absolute path after following a symlink, or the path as provided to stat if the file is not a symlink.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
|
||||
|
6
lib.go
6
lib.go
@ -1432,7 +1432,11 @@ var stdLibrary = vars{
|
||||
if err == nil {
|
||||
out[5] = []expression{"is-symlink?", true}
|
||||
if !filepath.IsAbs(ln) {
|
||||
ln = ExpandedAbsFilepath(filepath.Join(filepath.Dir(fp), ln))
|
||||
root := fp
|
||||
if !info.IsDir() {
|
||||
root = filepath.Dir(fp)
|
||||
}
|
||||
ln = ExpandedAbsFilepath(filepath.Join(root, ln))
|
||||
}
|
||||
out[6] = []expression{"path", ln}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user