equal
deleted
inserted
replaced
85 group = convertor.from_bytes(gr->gr_name); |
85 group = convertor.from_bytes(gr->gr_name); |
86 } |
86 } |
87 |
87 |
88 string_t getXattr(const fs::path& file, const string_t& attributeName) { |
88 string_t getXattr(const fs::path& file, const string_t& attributeName) { |
89 // TODO: review, test on multiple platforms |
89 // TODO: review, test on multiple platforms |
|
90 // TODO: improve documentation in xattr.h in glibc |
|
91 // TODO: check XATTR_NAME_MAX in limits.h and if it is reasonably small on our system, allocate buffer for it instead of reading twice |
|
92 // TODO: avoid race condition (another process might change the attribute between reading its length and its value) |
90 ssize_t length = getxattr(file.c_str(), convertor.to_bytes(attributeName).c_str(), nullptr, 0); |
93 ssize_t length = getxattr(file.c_str(), convertor.to_bytes(attributeName).c_str(), nullptr, 0); |
91 if (length > 0) { |
94 if (length > 0) { |
92 std::vector<char> buffer(length + 1); |
95 std::vector<char> buffer(length + 1); |
93 getxattr(file.c_str(), convertor.to_bytes(attributeName).c_str(), buffer.data(), length); |
96 getxattr(file.c_str(), convertor.to_bytes(attributeName).c_str(), buffer.data(), buffer.size()); |
94 return convertor.from_bytes(buffer.data()); |
97 return convertor.from_bytes(buffer.data()); |
95 } else { |
98 } else { |
96 return L""; |
99 return L""; |
97 } |
100 } |
98 } |
101 } |