aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/file.c20
-rw-r--r--src/core/file.h8
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/file.c b/src/core/file.c
index d7000a6a..4715be2a 100644
--- a/src/core/file.c
+++ b/src/core/file.c
@@ -28,6 +28,26 @@ nni_file_delete(const char *name)
return (nni_plat_file_delete(name));
}
+bool
+nni_file_is_file(const char *name)
+{
+ int ft;
+ if ((nni_file_type(name, &ft) == 0) && (ft == NNI_FILE_TYPE_FILE)) {
+ return (true);
+ }
+ return (false);
+}
+
+bool
+nni_file_is_dir(const char *name)
+{
+ int ft;
+ if ((nni_file_type(name, &ft) == 0) && (ft == NNI_FILE_TYPE_DIR)) {
+ return (true);
+ }
+ return (false);
+}
+
struct walkdata {
nni_file_walker fn;
void * arg;
diff --git a/src/core/file.h b/src/core/file.h
index b45aae61..7969ae5f 100644
--- a/src/core/file.h
+++ b/src/core/file.h
@@ -76,4 +76,12 @@ extern char *nni_file_join(const char *, const char *);
// The returned value generally is within the supplied path name.
extern const char *nni_file_basename(const char *);
+// nni_file_is_file returns true if the path references a file. It returns
+// false if an error occurs, or the path references something else.
+extern bool nni_file_is_file(const char *);
+
+// nni_file_is_dir returns true if the path references a directroy. It returns
+// false if an error occurs, or the path references something else.
+extern bool nni_file_is_dir(const char *);
+
#endif // CORE_FILE_H