Added pull request #1189: Fix os::native_is_{file,dir} bug. Add tests.

This commit is contained in:
Christoffer Lerno
2024-07-15 03:02:54 +02:00
parent 24041ed80d
commit bc0d52142a
3 changed files with 19 additions and 2 deletions

View File

@@ -95,7 +95,7 @@ fn bool native_is_file(String path)
$case env::DARWIN:
$case env::LINUX:
Stat stat;
return @ok(native_stat(&stat, path)) && stat.st_mode & libc::S_IFREG;
return @ok(native_stat(&stat, path)) && libc_S_ISTYPE(stat.st_mode, libc::S_IFREG);
$default:
File! f = file::open(path, "r");
defer (void)f.close();
@@ -107,7 +107,7 @@ fn bool native_is_dir(String path)
{
$if env::DARWIN || env::LINUX:
Stat stat;
return @ok(native_stat(&stat, path)) && stat.st_mode & libc::S_IFDIR;
return @ok(native_stat(&stat, path)) && libc_S_ISTYPE(stat.st_mode, libc::S_IFDIR);
$else
return native_file_or_dir_exists(path) && !native_is_file(path);
$endif