From 1e2da25d3da075c87fababccae0c58d6ffa7df21 Mon Sep 17 00:00:00 2001 From: Thomas Wienecke Date: Tue, 25 Feb 2014 17:03:04 +0100 Subject: [PATCH] os_unix: Use libuv uv_cwd instead of getcwd/getwd. --- src/eval.c | 1 + src/fileio.c | 1 + src/mark.c | 1 + src/os/fs.c | 14 ++++++++++++++ src/os/os.h | 1 + src/os_unix.c | 18 ------------------ src/proto/os_unix.pro | 1 - src/quickfix.c | 1 + 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/eval.c b/src/eval.c index 1ad5cf6eae..51519bb899 100644 --- a/src/eval.c +++ b/src/eval.c @@ -12,6 +12,7 @@ */ #include "vim.h" +#include "os/os.h" diff --git a/src/fileio.c b/src/fileio.c index e4d261d902..8dc31c31c6 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -12,6 +12,7 @@ */ #include "vim.h" +#include "os/os.h" #if defined(HAVE_UTIME) && defined(HAVE_UTIME_H) diff --git a/src/mark.c b/src/mark.c index 67888912d8..52f51b7679 100644 --- a/src/mark.c +++ b/src/mark.c @@ -12,6 +12,7 @@ */ #include "vim.h" +#include "os/os.h" /* * This file contains routines to maintain and manipulate marks. diff --git a/src/os/fs.c b/src/os/fs.c index 358b07e57b..e9a76c6b79 100644 --- a/src/os/fs.c +++ b/src/os/fs.c @@ -23,3 +23,17 @@ int mch_chdir(char *path) { } return uv_chdir(path); } + +/* + * Get name of current directory into buffer 'buf' of length 'len' bytes. + * Return OK for success, FAIL for failure. + */ +int mch_dirname(char_u *buf, int len) +{ + int errno; + if ((errno = uv_cwd((char *)buf, len)) != 0) { + STRCPY(buf, uv_strerror(errno)); + return FAIL; + } + return OK; +} diff --git a/src/os/os.h b/src/os/os.h index 58d49d36e7..099f53312f 100644 --- a/src/os/os.h +++ b/src/os/os.h @@ -5,5 +5,6 @@ long_u mch_total_mem(int special); int mch_chdir(char *path); +int mch_dirname(char_u *buf, int len); #endif diff --git a/src/os_unix.c b/src/os_unix.c index f65b285ba7..2bfddafc6c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1244,24 +1244,6 @@ static char * strerror(int err) } #endif -/* - * Get name of current directory into buffer 'buf' of length 'len' bytes. - * Return OK for success, FAIL for failure. - */ -int mch_dirname(char_u *buf, int len) -{ -#if defined(USE_GETCWD) - if (getcwd((char *)buf, len) == NULL) { - STRCPY(buf, strerror(errno)); - return FAIL; - } - return OK; -#else - return getwd((char *)buf) != NULL ? OK : FAIL; -#endif -} - - /* * Get absolute file name into "buf[len]". * diff --git a/src/proto/os_unix.pro b/src/proto/os_unix.pro index 7c5c62a786..64be80500c 100644 --- a/src/proto/os_unix.pro +++ b/src/proto/os_unix.pro @@ -27,7 +27,6 @@ int mch_get_user_name __ARGS((char_u *s, int len)); int mch_get_uname __ARGS((uid_t uid, char_u *s, int len)); void mch_get_host_name __ARGS((char_u *s, int len)); long mch_get_pid __ARGS((void)); -int mch_dirname __ARGS((char_u *buf, int len)); void slash_adjust __ARGS((char_u *p)); int mch_FullName __ARGS((char_u *fname, char_u *buf, int len, int force)); int mch_isFullName __ARGS((char_u *fname)); diff --git a/src/quickfix.c b/src/quickfix.c index 5fa175c0cb..a141d9834b 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -12,6 +12,7 @@ */ #include "vim.h" +#include "os/os.h" struct dir_stack_T {