80 static const string_t FIELD_OWNER; |
80 static const string_t FIELD_OWNER; |
81 static const string_t FIELD_GROUP; |
81 static const string_t FIELD_GROUP; |
82 |
82 |
83 virtual vector<AttributeMetadata> toMetadata(const RequestedField& field) override { |
83 virtual vector<AttributeMetadata> toMetadata(const RequestedField& field) override { |
84 if (field.group == RequestedField::GROUP_FILE) { |
84 if (field.group == RequestedField::GROUP_FILE) { |
85 if (field.name == FIELD_SIZE) return { AttributeMetadata{field.name, TypeId::INTEGER}}; |
85 vector<AttributeMetadata> metadata; |
86 else return { AttributeMetadata{field.name, TypeId::STRING}}; |
86 for (string_t alias : field.getAliases()) { |
|
87 if (field.name == FIELD_SIZE) metadata.push_back(AttributeMetadata{alias, TypeId::INTEGER}); |
|
88 else metadata.push_back(AttributeMetadata{alias, TypeId::STRING}); |
|
89 } |
|
90 return metadata; |
87 } else { |
91 } else { |
88 return {}; |
92 return {}; |
89 } |
93 } |
90 } |
94 } |
91 |
95 |
98 currentGroup.clear(); |
102 currentGroup.clear(); |
99 }; |
103 }; |
100 |
104 |
101 virtual void writeField(RelationalWriter* writer, const RequestedField& field) override { |
105 virtual void writeField(RelationalWriter* writer, const RequestedField& field) override { |
102 if (field.group == RequestedField::GROUP_FILE) { |
106 if (field.group == RequestedField::GROUP_FILE) { |
103 if (field.name == FIELD_NAME) { |
107 for (string_t alias : field.getAliases()) { |
104 writer->writeAttribute(currentFile.filename().wstring()); |
108 if (field.name == FIELD_NAME) { |
105 } else if (field.name == FIELD_PATH_ORIGINAL) { |
109 writer->writeAttribute(currentFile.filename().wstring()); |
106 writer->writeAttribute(currentFile.wstring()); |
110 } else if (field.name == FIELD_PATH_ORIGINAL) { |
107 } else if (field.name == FIELD_PATH_ABSOLUTE) { |
111 writer->writeAttribute(currentFile.wstring()); |
108 writer->writeAttribute(fs::absolute(currentFile).wstring()); |
112 } else if (field.name == FIELD_PATH_ABSOLUTE) { |
109 } else if (field.name == FIELD_PATH_CANONICAL) { |
113 writer->writeAttribute(fs::absolute(currentFile).wstring()); |
110 writer->writeAttribute(fs::canonical(currentFile).wstring()); |
114 } else if (field.name == FIELD_PATH_CANONICAL) { |
111 } else if (field.name == FIELD_TYPE) { |
115 writer->writeAttribute(fs::canonical(currentFile).wstring()); |
112 writer->writeAttribute(getType(currentFile)); |
116 } else if (field.name == FIELD_TYPE) { |
113 } else if (field.name == FIELD_SIZE) { |
117 writer->writeAttribute(getType(currentFile)); |
114 integer_t size = fs::is_regular_file(currentFile) ? fs::file_size(currentFile) : 0; |
118 } else if (field.name == FIELD_SIZE) { |
115 writer->writeAttribute(&size, typeid (size)); |
119 integer_t size = fs::is_regular_file(currentFile) ? fs::file_size(currentFile) : 0; |
116 } else if (field.name == FIELD_OWNER) { |
120 writer->writeAttribute(&size, typeid (size)); |
117 if (currentOwner.empty()) fetchOwner(currentFile, currentOwner, currentGroup); |
121 } else if (field.name == FIELD_OWNER) { |
118 writer->writeAttribute(currentOwner); |
122 if (currentOwner.empty()) fetchOwner(currentFile, currentOwner, currentGroup); |
119 } else if (field.name == FIELD_GROUP) { |
123 writer->writeAttribute(currentOwner); |
120 if (currentOwner.empty()) fetchOwner(currentFile, currentOwner, currentGroup); |
124 } else if (field.name == FIELD_GROUP) { |
121 writer->writeAttribute(currentGroup); |
125 if (currentOwner.empty()) fetchOwner(currentFile, currentOwner, currentGroup); |
122 } else { |
126 writer->writeAttribute(currentGroup); |
123 // TODO: should not happend; check supported attributes in toMetadata()? |
127 } else { |
124 writer->writeAttribute(L""); |
128 // TODO: should not happend; check supported attributes in toMetadata()? |
|
129 writer->writeAttribute(L""); |
|
130 } |
125 } |
131 } |
126 } |
132 } |
127 } |
133 } |
128 |
134 |
129 virtual ~FileAttributeFinder() override { |
135 virtual ~FileAttributeFinder() override { |