port vim_mkdir, mch_rmdir and mch_remove to libuv

This commit is contained in:
Stefan Hoffmann
2014-04-08 20:46:42 +02:00
committed by Thiago de Arruda
parent 136e5e5b84
commit 445f31f076
6 changed files with 92 additions and 11 deletions

View File

@@ -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>

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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