aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorThomas Wienecke <wienecke.t@gmail.com>2014-02-25 20:50:23 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-02-25 18:59:22 -0300
commit8437a4c9724f17824c9043afc27288013d096649 (patch)
treebc2f50c4ff98ea32760537a781c4e1a7bbcd23f7 /src/os_unix.c
parent60280ffa1095cf62e9c4892177c1ccc47db4f8f8 (diff)
downloadrneovim-8437a4c9724f17824c9043afc27288013d096649.tar.gz
rneovim-8437a4c9724f17824c9043afc27288013d096649.tar.bz2
rneovim-8437a4c9724f17824c9043afc27288013d096649.zip
os_unix: Port mch_FullName and mch_isFullName to libuv.
Basically just delete conditional use of fchdir, since the other called mch_* functions are already ported to libuv.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c121
1 files changed, 0 insertions, 121 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 2bfddafc6c..4bc4024abb 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1244,127 +1244,6 @@ static char * strerror(int err)
}
#endif
-/*
- * Get absolute file name into "buf[len]".
- *
- * return FAIL for failure, OK for success
- */
-int mch_FullName(
- char_u *fname,
- char_u *buf,
- int len,
- int force /* also expand when already absolute path */
- )
-{
- int l;
-#ifdef HAVE_FCHDIR
- int fd = -1;
- static int dont_fchdir = FALSE; /* TRUE when fchdir() doesn't work */
-#endif
- char_u olddir[MAXPATHL];
- char_u *p;
- int retval = OK;
-
-
-
- /* expand it if forced or not an absolute path */
- if (force || !mch_isFullName(fname)) {
- /*
- * If the file name has a path, change to that directory for a moment,
- * and then do the getwd() (and get back to where we were).
- * This will get the correct path name with "../" things.
- */
- if ((p = vim_strrchr(fname, '/')) != NULL) {
-#ifdef HAVE_FCHDIR
- /*
- * Use fchdir() if possible, it's said to be faster and more
- * reliable. But on SunOS 4 it might not work. Check this by
- * doing a fchdir() right now.
- */
- if (!dont_fchdir) {
- fd = open(".", O_RDONLY | O_EXTRA, 0);
- if (fd >= 0 && fchdir(fd) < 0) {
- close(fd);
- fd = -1;
- dont_fchdir = TRUE; /* don't try again */
- }
- }
-#endif
-
- /* Only change directory when we are sure we can return to where
- * we are now. After doing "su" chdir(".") might not work. */
- if (
-#ifdef HAVE_FCHDIR
- fd < 0 &&
-#endif
- (mch_dirname(olddir, MAXPATHL) == FAIL
- || mch_chdir((char *)olddir) != 0)) {
- p = NULL; /* can't get current dir: don't chdir */
- retval = FAIL;
- } else {
- /* The directory is copied into buf[], to be able to remove
- * the file name without changing it (could be a string in
- * read-only memory) */
- if (p - fname >= len)
- retval = FAIL;
- else {
- vim_strncpy(buf, fname, p - fname);
- if (mch_chdir((char *)buf))
- retval = FAIL;
- else
- fname = p + 1;
- *buf = NUL;
- }
- }
- }
- if (mch_dirname(buf, len) == FAIL) {
- retval = FAIL;
- *buf = NUL;
- }
- if (p != NULL) {
-#ifdef HAVE_FCHDIR
- if (fd >= 0) {
- if (p_verbose >= 5) {
- verbose_enter();
- MSG("fchdir() to previous dir");
- verbose_leave();
- }
- l = fchdir(fd);
- close(fd);
- } else
-#endif
- l = mch_chdir((char *)olddir);
- if (l != 0)
- EMSG(_(e_prev_dir));
- }
-
- l = STRLEN(buf);
- if (l >= len - 1)
- retval = FAIL; /* no space for trailing "/" */
- else if (l > 0 && buf[l - 1] != '/' && *fname != NUL
- && STRCMP(fname, ".") != 0)
- STRCAT(buf, "/");
- }
-
- /* Catch file names which are too long. */
- if (retval == FAIL || (int)(STRLEN(buf) + STRLEN(fname)) >= len)
- return FAIL;
-
- /* Do not append ".", "/dir/." is equal to "/dir". */
- if (STRCMP(fname, ".") != 0)
- STRCAT(buf, fname);
-
- return OK;
-}
-
-/*
- * Return TRUE if "fname" does not depend on the current directory.
- */
-int mch_isFullName(char_u *fname)
-{
- return *fname == '/' || *fname == '~';
-}
-
#if defined(USE_FNAME_CASE) || defined(PROTO)
/*
* Set the case of the file name, if it already exists. This will cause the