aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorThomas Wienecke <wienecke.t@gmail.com>2014-03-14 22:55:14 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-15 11:50:22 -0300
commit1949acc806e89dc0d2766b2b41eae1cac3186642 (patch)
tree1baad3b84e7ce42b7394e8ccc66670845cc5ccaf /src/os
parentc83e8b4dc74ba010e0279b67ef8ffa14103d89f6 (diff)
downloadrneovim-1949acc806e89dc0d2766b2b41eae1cac3186642.tar.gz
rneovim-1949acc806e89dc0d2766b2b41eae1cac3186642.tar.bz2
rneovim-1949acc806e89dc0d2766b2b41eae1cac3186642.zip
Revive vim_fname (-> os_file_exists); fix misuse of mch_getperm.
* Move vim_fname from misc1 to os/fs:os_file_exists. * Add unit tests for os_file_exists. * Replace misuse of mch_getperm with os_file_exists.
Diffstat (limited to 'src/os')
-rw-r--r--src/os/fs.c17
-rw-r--r--src/os/os.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/os/fs.c b/src/os/fs.c
index 4c1b05b678..aa19b2f7f7 100644
--- a/src/os/fs.c
+++ b/src/os/fs.c
@@ -315,3 +315,20 @@ int mch_setperm(const char_u *name, int perm)
return OK;
}
}
+
+/*
+ * return TRUE if "name" exists.
+ */
+int os_file_exists(char_u *name)
+{
+ uv_fs_t request;
+ int result = uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL);
+ uv_fs_req_cleanup(&request);
+
+ if (result != 0) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
diff --git a/src/os/os.h b/src/os/os.h
index 5a8c8fc005..2bfcd8f162 100644
--- a/src/os/os.h
+++ b/src/os/os.h
@@ -19,5 +19,6 @@ int mch_get_uname(uid_t uid, char *s, size_t len);
char *mch_get_user_directory(const char *name);
long mch_getperm(const char_u *name);
int mch_setperm(const char_u *name, int perm);
+int os_file_exists(char_u *name);
#endif