fix •file.Type when file not present
This commit is contained in:
parent
47c8c1e5de
commit
eae7501d36
@ -676,7 +676,9 @@ B list_c1(B d, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B ftype_c1(B d, B x) {
|
B ftype_c1(B d, B x) {
|
||||||
return m_c32(path_type(path_rel(nfn_objU(d), x)));
|
char ty = path_type(path_rel(nfn_objU(d), x));
|
||||||
|
if (ty==0) thrM("•file.Type: Error while accessing file");
|
||||||
|
return m_c32(ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
B fName_c1(B t, B x) {
|
B fName_c1(B t, B x) {
|
||||||
|
|||||||
@ -224,8 +224,11 @@ B path_list(B path) {
|
|||||||
char path_type(B path) {
|
char path_type(B path) {
|
||||||
char* p = toCStr(path);
|
char* p = toCStr(path);
|
||||||
struct stat path_stat;
|
struct stat path_stat;
|
||||||
stat(p, &path_stat);
|
int r = stat(p, &path_stat);
|
||||||
freeCStr(p);
|
freeCStr(p);
|
||||||
|
dec(path);
|
||||||
|
|
||||||
|
if (r==-1) return 0;
|
||||||
i64 mode = path_stat.st_mode;
|
i64 mode = path_stat.st_mode;
|
||||||
if (S_ISREG (mode)) return 'f';
|
if (S_ISREG (mode)) return 'f';
|
||||||
if (S_ISDIR (mode)) return 'd';
|
if (S_ISDIR (mode)) return 'd';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user