taisei/src/vfs/syspath_public.c
2019-08-03 20:44:22 +03:00

40 lines
1,016 B
C

/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#include "taisei.h"
#include "syspath.h"
#include "readonly_wrapper.h"
bool vfs_mount_syspath(const char *mountpoint, const char *fspath, uint flags) {
VFSNode *rdir = vfs_alloc();
if(!vfs_syspath_init(rdir, fspath)) {
vfs_set_error("Can't initialize path: %s", vfs_get_error());
vfs_decref(rdir);
return false;
}
if((flags & VFS_SYSPATH_MOUNT_MKDIR) && !vfs_node_mkdir(rdir, NULL)) {
vfs_set_error("Can't create directory: %s", vfs_get_error());
vfs_decref(rdir);
return false;
}
if(flags & VFS_SYSPATH_MOUNT_READONLY) {
VFSNode *rdir_ro = vfs_ro_wrap(rdir);
vfs_decref(rdir);
rdir = rdir_ro;
}
return vfs_mount_or_decref(vfs_root, mountpoint, rdir);
}
char vfs_get_syspath_separator(void) {
return vfs_syspath_separators[0];
}