Beispiel #1
0
/* canonize the path and make it absolute */
void canonize_absolute_path(char *buf, int buf_size, const char *path1)
{
    char cwd[MAX_FILENAME_SIZE];
    char path[MAX_FILENAME_SIZE];
    char *homedir;

    if (!is_abs_path(path1)) {
        /* XXX: should call it again */
        if (*path1 == '~' && (path1[1] == '\0' || path1[1] == '/')) {
            homedir = getenv("HOME");
            if (homedir) {
                pstrcpy(path, sizeof(path), homedir);
                pstrcat(path, sizeof(path), path1 + 1);
                goto next;
            }
        }
        /* CG: not sufficient for windows drives */
        getcwd(cwd, sizeof(cwd));
#ifdef WIN32
        path_win_to_unix(cwd);
#endif
        makepath(path, sizeof(path), cwd, path1);
    } else {
        pstrcpy(path, sizeof(path), path1);
    }
next:
    canonize_path(buf, buf_size, path);
}
Beispiel #2
0
/* canonize the path and make it absolute */
void canonize_absolute_path_old(char *buf, int buf_size, const char *path1)
{
    char path[1024];

    if (!is_abs_path(path1)) {
        /* XXX: should call it again */
        getcwd(path, sizeof(path));
#ifdef WIN32
        path_win_to_unix(path);
#endif
        pstrcat(path, sizeof(path), "/");
        pstrcat(path, sizeof(path), path1);
    } else {
        pstrcpy(path, sizeof(path), path1);
    }
    canonize_path(buf, buf_size, path);
}
Beispiel #3
0
Datei: util.c Projekt: kjk/qemacs
/* canonize the path and make it absolute */
void canonize_absolute_path(char *buf, int buf_size, const char *path1)
{
    char cwd[MAX_FILENAME_SIZE];
    char path[MAX_FILENAME_SIZE];

    if (is_abs_path(path1)) {
        pstrcpy(path, sizeof(path), path1);
    } else {
        /* CG: not sufficient for windows drives */
        if (!expand_unix_home(path1, path, sizeof(path))) {
            getcwd(cwd, sizeof(cwd));
            path_win_to_unix(cwd);
            makepath(path, sizeof(path), cwd, path1);
        }
    }
    canonize_path(buf, buf_size, path);
}
Beispiel #4
0
/* canonicalize the path and make it absolute */
void canonize_absolute_path(char *buf, int buf_size, const char *path1)
{
    char cwd[MAX_FILENAME_SIZE];
    char path[MAX_FILENAME_SIZE];
    
    if (!is_abs_path(path1)) {
        if (*path1 == '~') {
           tilde_expand(path, MAX_FILENAME_SIZE, path1);
           path1 = path;
        } else {
            /* CG: not sufficient for windows drives */
            /* CG: should test result */
            getcwd(cwd, sizeof(cwd));
#ifdef CONFIG_WIN32
            path_win_to_unix(cwd);
#endif
            makepath(path, sizeof(path), cwd, path1);
            path1 = path;
        }
    }
    canonize_path(buf, buf_size, path1);
}