本文整理汇总了C++中FileSystem::access方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::access方法的具体用法?C++ FileSystem::access怎么用?C++ FileSystem::access使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::access方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: archivefs_opendir
int archivefs_opendir(const char *path, struct fuse_file_info *info) {
char fpath[PATH_MAX];
fullpath(fpath, path);
/* Stejná logika jako u archivefs_open.
*/
DIR* dir;
if ((dir = opendir(fpath)) != NULL) {
info->fh = intptr_t(dir);
return 0;
}
FileSystem* fs;
FileNode* node;
if (!getFile(fpath, &fs, &node)) {
print_err("OPENDIR", path, ENOENT);
return -ENOENT;
}
struct fuse_context* context = fuse_get_context();
if (fs->access(node, R_OK, context->uid, context->gid))
return -EACCES;
info->fh = intptr_t(new FileHandle(fs, node));
return 0;
}
示例2: archivefs_truncate
int archivefs_truncate(const char* path, off_t size) {
char fpath[PATH_MAX];
fullpath(fpath, path);
FileSystem* fs;
FileNode* node;
int ret;
if (!getFile(fpath, &fs, &node)) {
ret = truncate(fpath, size);
if (ret) {
ret = errno;
}
} else {
struct fuse_context* context = fuse_get_context();
if (fs->access(node, W_OK, context->uid, context->gid))
return -EACCES;
ret = fs->truncate(node, size);
}
if (ret)
print_err("TRUNCATE", path, ret);
return -ret;
}
示例3: archivefs_open
int archivefs_open(const char* path, struct fuse_file_info* info) {
char fpath[PATH_MAX];
fullpath(fpath, path);
/* Nejprve se pokusím otevřít soubor s cestou path jakoby byl přítomen
* fyzicky na disku - použiju systémový open.
* Pokud volání této funkce selže, jedná se o soubor uvnitř archivu.
*/
int fd;
if ((fd = open(fpath, info->flags)) != -1) {
info->fh = intptr_t(fd);
return 0;
}
FileSystem* fs;
FileNode* node;
if (!getFile(fpath, &fs, &node)) {
print_err("OPEN", path, ENOENT);
return -ENOENT;
}
int ret;
struct fuse_context* context = fuse_get_context();
if (info->flags & O_RDWR) {
if (fs->access(node, R_OK|W_OK, context->uid, context->gid))
return -EACCES;
} else if (info->flags & O_WRONLY) {
if (fs->access(node, W_OK, context->uid, context->gid))
return -EACCES;
} else {
if (fs->access(node, R_OK, context->uid, context->gid))
return -EACCES;
}
if ((ret = fs->open(node, info->flags)) < 0) {
print_err("OPEN", path, ret);
return -ret;
}
info->fh = intptr_t(new FileHandle(fs, node));
return 0;
}
示例4: archivefs_access
int archivefs_access(const char* path, int mask) {
char fpath[PATH_MAX];
fullpath(fpath, path);
FileSystem* fs;
FileNode* node;
int ret;
struct fuse_context* context = fuse_get_context();
if (!getFile(fpath, &fs, &node)) {
ret = access(fpath, mask);
if (ret) {
ret = errno;
print_err("ACCESS", path, ret);
}
return -ret;
}
ret = fs->access(node, mask, context->uid, context->gid);
if (ret)
print_err("ACCESS", path, ret);
return -ret;
}