예제 #1
0
파일: filenot.c 프로젝트: BpArCuCTeMbI/mc
static int
my_mkdir_rec (const vfs_path_t * s_vpath, mode_t mode)
{
    vfs_path_t *q;
    int result;

    if (mc_mkdir (s_vpath, mode) == 0)
        return 0;
    if (errno != ENOENT)
        return (-1);

    /* FIXME: should check instead if s_vpath is at the root of that filesystem */
    if (!vfs_file_is_local (s_vpath))
        return (-1);

    if (strcmp (vfs_path_as_str (s_vpath), PATH_SEP_STR) == 0)
    {
        errno = ENOTDIR;
        return (-1);
    }

    q = vfs_path_append_new (s_vpath, "..", NULL);
    result = my_mkdir_rec (q, mode);
    vfs_path_free (q);

    if (result == 0)
        result = mc_mkdir (s_vpath, mode);

    return result;
}
예제 #2
0
static int
my_mkdir_rec (char *s, mode_t mode)
{
    char *p, *q;
    int result;

    if (!mc_mkdir (s, mode))
	return 0;
    else if (errno != ENOENT)
	return -1;

    /* FIXME: should check instead if s is at the root of that filesystem */
    if (!vfs_file_is_local (s))
	return -1;

    if (!strcmp (s, PATH_SEP_STR)) {
	errno = ENOTDIR;
	return -1;
    }

    p = concat_dir_and_file (s, "..");
    q = vfs_canon (p);
    g_free (p);

    if (!(result = my_mkdir_rec (q, mode)))
	result = mc_mkdir (s, mode);

    g_free (q);
    return result;
}
예제 #3
0
int
my_mkdir (const char *s, mode_t mode)
{
    int result;
    char *my_s;

    result = mc_mkdir (s, mode);
    if (result)
    {
        char *p = vfs_canon (s);

        result = my_mkdir_rec (p, mode);
        g_free (p);
    }
    if (result == 0)
    {
        my_s = get_absolute_name (s);

#ifdef FIXME
        tree_add_entry (tree, my_s);
#endif

        g_free (my_s);
    }
    return result;
}