# HG changeset patch # User František Kučera # Date 1547658967 -3600 # Node ID 8d73bff730a7099eaa331173d839e584860f5534 # Parent 35607c973cf5c1c26588a4284ab563cce9b9acae add symlink link target field diff -r 35607c973cf5 -r 8d73bff730a7 src/CLIParser.h --- a/src/CLIParser.h Wed Jan 16 18:01:49 2019 +0100 +++ b/src/CLIParser.h Wed Jan 16 18:16:07 2019 +0100 @@ -41,7 +41,9 @@ // c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_PATH_CANONICAL)); // c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_NAME)); c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_TYPE)); + // c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_TYPE,{L"type_a", L"type_b"})); c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_SYMLINK_TARGET_TYPE)); + // c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_SYMLINK_TARGET)); c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_SIZE)); c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_OWNER)); c.fields.push_back(RequestedField(RequestedField::GROUP_FILE, FileAttributeFinder::FIELD_GROUP)); diff -r 35607c973cf5 -r 8d73bff730a7 src/FileAttributeFinder.h --- a/src/FileAttributeFinder.h Wed Jan 16 18:01:49 2019 +0100 +++ b/src/FileAttributeFinder.h Wed Jan 16 18:16:07 2019 +0100 @@ -78,6 +78,7 @@ static const string_t FIELD_PATH_CANONICAL; static const string_t FIELD_TYPE; static const string_t FIELD_SYMLINK_TARGET_TYPE; + static const string_t FIELD_SYMLINK_TARGET; static const string_t FIELD_OWNER; static const string_t FIELD_GROUP; @@ -118,6 +119,8 @@ writer->writeAttribute(getType(currentFile, true)); } else if (field.name == FIELD_SYMLINK_TARGET_TYPE) { writer->writeAttribute(getType(currentFile, false)); + } else if (field.name == FIELD_SYMLINK_TARGET) { + writer->writeAttribute(fs::is_symlink(currentFile) ? fs::read_symlink(currentFile).wstring() : L""); // TODO: null value (when supported) } else if (field.name == FIELD_SIZE) { integer_t size = fs::is_regular_file(currentFile) ? fs::file_size(currentFile) : 0; writer->writeAttribute(&size, typeid (size)); @@ -146,6 +149,7 @@ const string_t FileAttributeFinder::FIELD_PATH_CANONICAL = L"path_canonical"; const string_t FileAttributeFinder::FIELD_TYPE = L"type"; const string_t FileAttributeFinder::FIELD_SYMLINK_TARGET_TYPE = L"symlink_target_type"; +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"; diff -r 35607c973cf5 -r 8d73bff730a7 src/FilesystemCommand.h --- a/src/FilesystemCommand.h Wed Jan 16 18:01:49 2019 +0100 +++ b/src/FilesystemCommand.h Wed Jan 16 18:16:07 2019 +0100 @@ -101,13 +101,14 @@ for (RequestedField field : configuration.fields) { AttributeFinder* finder = attributeFinders[field.group]; // should not be nullptr, because already checked while writing the relation metadata + // TODO: links to non-existent files are currently treated as non-existent files → we still can return the type and symlink_target values if (exists || (field.group == RequestedField::GROUP_FILE && field.name == FileAttributeFinder::FIELD_PATH_ORIGINAL)) { finder->writeField(writer.get(), field); } else { finder->writeEmptyField(writer.get(), field); } } - + for (auto& finder : attributeFinders) finder.second->endFile(); } }