`ls` and file.h: massive ls function cleanup.
moved file functions (isRegularFile, isDirectory, isSymlink) into file.h. commented out printBool, as it should only be needed when debugging. made remaining function static.master
parent
005327533e
commit
a839c81518
@ -0,0 +1,20 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
static _Bool isRegularFile(const char *path)
|
||||
{
|
||||
struct stat path_stat;
|
||||
lstat(path, &path_stat);
|
||||
return S_ISREG(path_stat.st_mode);
|
||||
}
|
||||
|
||||
static _Bool isDirectory(const char *path) {
|
||||
struct stat path_stat;
|
||||
lstat(path, &path_stat);
|
||||
return S_ISDIR(path_stat.st_mode);
|
||||
}
|
||||
|
||||
static _Bool isSymlink(const char *path) {
|
||||
struct stat path_stat;
|
||||
lstat(path, &path_stat);
|
||||
return S_ISLNK(path_stat.st_mode);
|
||||
}
|
Loading…
Reference in new issue