aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Hoffmann <stefan991@gmail.com>2014-04-08 20:46:42 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-11 13:31:48 -0300
commit445f31f076325a68d91746bb41ac9ba139144c2d (patch)
treedd05a6d09822572ae152be6b3759696d8ebf6901 /src
parent136e5e5b84469559e72e061b2c6e78db18174a12 (diff)
downloadrneovim-445f31f076325a68d91746bb41ac9ba139144c2d.tar.gz
rneovim-445f31f076325a68d91746bb41ac9ba139144c2d.tar.bz2
rneovim-445f31f076325a68d91746bb41ac9ba139144c2d.zip
port vim_mkdir, mch_rmdir and mch_remove to libuv
Diffstat (limited to 'src')
-rw-r--r--src/if_cscope.c1
-rw-r--r--src/memfile.c1
-rw-r--r--src/os/fs.c25
-rw-r--r--src/os/os.h15
-rw-r--r--src/os_unix_defs.h11
5 files changed, 45 insertions, 8 deletions
diff --git a/src/if_cscope.c b/src/if_cscope.c
index e257e4e84b..65155c3421 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -24,6 +24,7 @@
#include "tag.h"
#include "ui.h"
#include "window.h"
+#include "os/os.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/src/memfile.c b/src/memfile.c
index 7a9b062d58..30a5ed389d 100644
--- a/src/memfile.c
+++ b/src/memfile.c
@@ -45,6 +45,7 @@
#include "os_unix.h"
#include "path.h"
#include "ui.h"
+#include "os/os.h"
/*
* Some systems have the page size in statfs.f_bsize, some in stat.st_blksize
diff --git a/src/os/fs.c b/src/os/fs.c
index a68e66ef00..f9b02375e1 100644
--- a/src/os/fs.c
+++ b/src/os/fs.c
@@ -202,3 +202,28 @@ int os_rename(const char_u *path, const char_u *new_path)
return FAIL;
}
+
+int os_mkdir(const char *path, int32_t mode)
+{
+ uv_fs_t request;
+ int result = uv_fs_mkdir(uv_default_loop(), &request, path, mode, NULL);
+ uv_fs_req_cleanup(&request);
+ return result;
+}
+
+int os_rmdir(const char *path)
+{
+ uv_fs_t request;
+ int result = uv_fs_rmdir(uv_default_loop(), &request, path, NULL);
+ uv_fs_req_cleanup(&request);
+ return result;
+}
+
+int os_remove(const char *path)
+{
+ uv_fs_t request;
+ int result = uv_fs_unlink(uv_default_loop(), &request, path, NULL);
+ uv_fs_req_cleanup(&request);
+ return result;
+}
+
diff --git a/src/os/os.h b/src/os/os.h
index ff21a95f3a..45bec739f5 100644
--- a/src/os/os.h
+++ b/src/os/os.h
@@ -63,6 +63,21 @@ int os_file_is_writable(const char *name);
/// @return `OK` for success, `FAIL` for failure.
int os_rename(const char_u *path, const char_u *new_path);
+/// Make a directory.
+///
+/// @return `0` for success, non-zero for failure.
+int os_mkdir(const char *path, int32_t mode);
+
+/// Remove a directory.
+///
+/// @return `0` for success, non-zero for failure.
+int os_rmdir(const char *path);
+
+/// Remove a file.
+///
+/// @return `0` for success, non-zero for failure.
+int os_remove(const char *path);
+
long_u os_total_mem(int special);
const char *os_getenv(const char *name);
int os_setenv(const char *name, const char *value, int overwrite);
diff --git a/src/os_unix_defs.h b/src/os_unix_defs.h
index 54627b5b7d..621e461030 100644
--- a/src/os_unix_defs.h
+++ b/src/os_unix_defs.h
@@ -30,14 +30,9 @@
# include <sys/param.h> /* defines BSD, if it's a BSD system */
#endif
-/*
- * Sun defines FILE on SunOS 4.x.x, Solaris has a typedef for FILE
- */
-
-/* always use unlink() to remove files */
-# define vim_mkdir(x, y) mkdir((char *)(x), y)
-# define mch_rmdir(x) rmdir((char *)(x))
-# define mch_remove(x) unlink((char *)(x))
+#define vim_mkdir(x, y) os_mkdir((char *)(x), (y))
+#define mch_rmdir(x) os_rmdir((char *)(x))
+#define mch_remove(x) os_remove((char *)(x))
/* The number of arguments to a signal handler is configured here. */
/* It used to be a long list of almost all systems. Any system that doesn't