blob: 44aa7652478d02e0d8da7547ca2e137d2380648c (
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
65
66
|
#include <Ice/ObjectAdapter.h>
#include <dirent.h>
#include <cerrno>
#include <map>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include "daemonDirectory.h"
DirectoryServer::DirectoryServer(DIR * d, EntryTypeConverter & t) :
EntryTypeConverter(t),
od(d)
{
}
void
DirectoryServer::close(const Ice::Current & ice)
{
errno = 0;
if (::closedir(od) != 0) {
// LCOV_EXCL_START
throw NetFS::SystemError(errno);
// LCOV_EXCL_STOP
}
ice.adapter->removeAllFacets(ice.id);
}
NetFS::NameList
DirectoryServer::readdir(const Ice::Current&)
{
errno = 0;
NetFS::NameList list;
while (dirent * d = ::readdir(od)) {
if (errno) {
// LCOV_EXCL_START
throw NetFS::SystemError(errno);
// LCOV_EXCL_STOP
}
list.emplace_back(d->d_name);
}
return list;
}
NetFS::DirectoryContents
DirectoryServer::listdir(const Ice::Current&)
{
errno = 0;
NetFS::DirectoryContents list;
int fd = dirfd(od);
while (dirent * d = ::readdir(od)) {
if (errno) {
// LCOV_EXCL_START
throw NetFS::SystemError(errno);
// LCOV_EXCL_STOP
}
struct stat s;
if (::fstatat(fd, d->d_name, &s, AT_SYMLINK_NOFOLLOW) != 0) {
// LCOV_EXCL_START
throw NetFS::SystemError(errno);
// LCOV_EXCL_STOP
}
list.emplace(d->d_name, convert(s));
}
return list;
}
|