diff -r 1bf848f24c53 -r 1252acdc5a5a src/FileAttributeFinder.h --- a/src/FileAttributeFinder.h Sun May 26 22:22:58 2019 +0200 +++ b/src/FileAttributeFinder.h Fri Jul 26 22:34:30 2019 +0200 @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include @@ -70,6 +72,20 @@ group = convertor.from_bytes(gr->gr_name); } + string_t getContent(const fs::path& file) { + // TODO: better copy + // not working: + wifstream source(file); + std::wstringstream result; + for (wchar_t ch; source.get(ch); source.good()) result << ch; + return result.str(); + + //wifstream stream(file); + //std::wstringstream content; + //content << stream.rdbuf(); + //return content.str(); + } + protected: virtual void writeFieldOfExistingFile(RelationalWriter* writer, const RequestedField& field) override { @@ -106,6 +122,8 @@ } else if (field.name == FIELD_GROUP) { if (currentOwner.empty()) fetchOwner(currentFile, currentOwner, currentGroup); writer->writeAttribute(currentGroup); + } else if (field.name == FIELD_CONTENT) { + writer->writeAttribute(getContent(currentFile)); } else { throw RelpipeWriterException(L"Unsupported field name in FileAttributeFinder: " + field.name); } @@ -125,6 +143,7 @@ static const string_t FIELD_SYMLINK_TARGET; static const string_t FIELD_OWNER; static const string_t FIELD_GROUP; + static const string_t FIELD_CONTENT; virtual vector toMetadata(const RequestedField& field) override { if (field.group == RequestedField::GROUP_FILE) { @@ -168,6 +187,7 @@ const string_t FileAttributeFinder::FIELD_SYMLINK_TARGET = L"symlink_target"; const string_t FileAttributeFinder::FIELD_OWNER = L"owner"; const string_t FileAttributeFinder::FIELD_GROUP = L"group"; +const string_t FileAttributeFinder::FIELD_CONTENT = L"content"; } }