# HG changeset patch # User František Kučera # Date 1547658109 -3600 # Node ID 35607c973cf5c1c26588a4284ab563cce9b9acae # Parent ec661baf433a7a5821a77da175b245e83dd79b75 distinguish link type and link target type diff -r ec661baf433a -r 35607c973cf5 src/CLIParser.h --- a/src/CLIParser.h Wed Jan 16 17:48:06 2019 +0100 +++ b/src/CLIParser.h Wed Jan 16 18:01:49 2019 +0100 @@ -41,6 +41,7 @@ // 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_SYMLINK_TARGET_TYPE)); 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 ec661baf433a -r 35607c973cf5 src/FileAttributeFinder.h --- a/src/FileAttributeFinder.h Wed Jan 16 17:48:06 2019 +0100 +++ b/src/FileAttributeFinder.h Wed Jan 16 18:01:49 2019 +0100 @@ -41,10 +41,10 @@ string_t currentOwner; string_t currentGroup; - string_t getType(const fs::path& file) { + string_t getType(const fs::path& file, bool x) { // TODO: Use whole words? (letters are compatible with find -type) - if (fs::is_regular_file(file)) return L"f"; - else if (fs::is_symlink(file)) return L"l"; // symlinks to directories are both symlinks and directories + if (fs::is_symlink(file) && x) return L"l"; // symlinks are both symlinks and files/directories/etc. + else if (fs::is_regular_file(file)) return L"f"; else if (fs::is_directory(file)) return L"d"; else if (fs::is_fifo(file)) return L"p"; else if (fs::is_socket(file)) return L"s"; @@ -77,6 +77,7 @@ static const string_t FIELD_PATH_ABSOLUTE; 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_OWNER; static const string_t FIELD_GROUP; @@ -114,7 +115,9 @@ } else if (field.name == FIELD_PATH_CANONICAL) { writer->writeAttribute(fs::canonical(currentFile).wstring()); } else if (field.name == FIELD_TYPE) { - writer->writeAttribute(getType(currentFile)); + writer->writeAttribute(getType(currentFile, true)); + } else if (field.name == FIELD_SYMLINK_TARGET_TYPE) { + writer->writeAttribute(getType(currentFile, false)); } else if (field.name == FIELD_SIZE) { integer_t size = fs::is_regular_file(currentFile) ? fs::file_size(currentFile) : 0; writer->writeAttribute(&size, typeid (size)); @@ -142,6 +145,7 @@ const string_t FileAttributeFinder::FIELD_PATH_ABSOLUTE = L"path_absolute"; 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_OWNER = L"owner"; const string_t FileAttributeFinder::FIELD_GROUP = L"group";