summaryrefslogtreecommitdiff
path: root/netfs/fuseDirs.cpp
blob: 846f1dea6e0e558291a8eb4fec291d885b8f9109 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "fuse.h"
#include "misc.h"

int
NetFS::opendir(const char * p, struct fuse_file_info * fi)
{
	try {
		fi->fh = dirs->opendir(p);
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::releasedir(const char *, struct fuse_file_info * fi)
{
	try {
		dirs->closedir(fi->fh);
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::readdir(const char *, void * buf, fuse_fill_dir_t filler, off_t, struct fuse_file_info * fi)
{
	try {
		NetFSComms::NameList ds = dirs->readdir(fi->fh);
		for (NetFSComms::NameList::const_iterator e = ds.begin(); e != ds.end(); e++) {
			filler(buf, e->c_str(), NULL, 0);
		}
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::mkdir(const char * p, mode_t m)
{
	try {
		dirs->mkdir(p, m);
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}
int
NetFS::rmdir(const char * p)
{
	try {
		dirs->rmdir(p);
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}