equal
deleted
inserted
replaced
35 |
35 |
36 class XattrAttributeFinder : public AttributeFinder { |
36 class XattrAttributeFinder : public AttributeFinder { |
37 private: |
37 private: |
38 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
38 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
39 |
39 |
40 fs::path currentFile; |
|
41 |
|
42 string_t getXattr(const fs::path& file, const string_t& attributeName) { |
40 string_t getXattr(const fs::path& file, const string_t& attributeName) { |
43 // TODO: review, test on multiple platforms |
41 // TODO: review, test on multiple platforms |
44 // TODO: improve documentation in xattr.h in glibc |
42 // TODO: improve documentation in xattr.h in glibc |
45 // 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 |
43 // 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 |
46 // TODO: avoid race condition (another process might change the attribute between reading its length and its value) |
44 // TODO: avoid race condition (another process might change the attribute between reading its length and its value) |
63 } else { |
61 } else { |
64 return {}; |
62 return {}; |
65 } |
63 } |
66 } |
64 } |
67 |
65 |
68 void startFile(const fs::path& file) override { |
|
69 currentFile = file; |
|
70 }; |
|
71 |
|
72 void endFile() override { |
|
73 }; |
|
74 |
|
75 virtual void writeField(RelationalWriter* writer, const RequestedField& field) override { |
66 virtual void writeField(RelationalWriter* writer, const RequestedField& field) override { |
76 for (string_t alias : field.getAliases()) { |
67 for (string_t alias : field.getAliases()) { |
77 if (field.group == RequestedField::GROUP_XATTR) writer->writeAttribute(getXattr(currentFile, field.name)); |
68 if (field.group == RequestedField::GROUP_XATTR) writer->writeAttribute(getXattr(currentFile, field.name)); |
78 } |
69 } |
79 } |
70 } |