mirror of
https://github.com/janet-lang/janet
synced 2024-12-27 00:40:26 +00:00
os/stat returns nil if file does not exist.
This commit is contained in:
parent
7d48e7fd1f
commit
ec6e2cfd62
@ -552,7 +552,7 @@ static Janet os_stat(int32_t argc, Janet *argv) {
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
int res = stat(path, &st);
|
int res = stat(path, &st);
|
||||||
if (-1 == res) {
|
if (-1 == res) {
|
||||||
janet_panicv(janet_cstringv(strerror(errno)));
|
return janet_wrap_nil()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getall) {
|
if (getall) {
|
||||||
@ -640,7 +640,7 @@ static const JanetReg os_cfuns[] = {
|
|||||||
"os/stat", os_stat,
|
"os/stat", os_stat,
|
||||||
JDOC("(os/stat path [, tab|key])\n\n"
|
JDOC("(os/stat path [, tab|key])\n\n"
|
||||||
"Gets information about a file or directory. Returns a table If the third argument is a keyword, returns "
|
"Gets information about a file or directory. Returns a table If the third argument is a keyword, returns "
|
||||||
" only that information from stat. The keys are\n\n"
|
" only that information from stat. If the file or directory does not exist, returns nil. The keys are\n\n"
|
||||||
"\t:dev - the device that the file is on\n"
|
"\t:dev - the device that the file is on\n"
|
||||||
"\t:mode - the type of file, one of :file, :directory, :block, :character, :fifo, :socket, :link, or :other\n"
|
"\t:mode - the type of file, one of :file, :directory, :block, :character, :fifo, :socket, :link, or :other\n"
|
||||||
"\t:permissions - A unix permission string like \"rwx--x--x\"\n"
|
"\t:permissions - A unix permission string like \"rwx--x--x\"\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user