storage/FileInfo: add initializing constructor
This commit is contained in:
src/storage
@ -86,12 +86,7 @@ CompositeDirectoryReader::GetInfo(bool follow)
|
|||||||
|
|
||||||
assert(current != names.end());
|
assert(current != names.end());
|
||||||
|
|
||||||
StorageFileInfo info;
|
return StorageFileInfo(StorageFileInfo::Type::DIRECTORY);
|
||||||
info.type = StorageFileInfo::Type::DIRECTORY;
|
|
||||||
info.mtime = 0;
|
|
||||||
info.device = 0;
|
|
||||||
info.inode = 0;
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string
|
static std::string
|
||||||
@ -280,14 +275,8 @@ CompositeStorage::GetInfo(const char *uri, bool follow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Directory *directory = f.directory->Find(f.uri);
|
const Directory *directory = f.directory->Find(f.uri);
|
||||||
if (directory != nullptr) {
|
if (directory != nullptr)
|
||||||
StorageFileInfo info;
|
return StorageFileInfo(StorageFileInfo::Type::DIRECTORY);
|
||||||
info.type = StorageFileInfo::Type::DIRECTORY;
|
|
||||||
info.mtime = 0;
|
|
||||||
info.device = 0;
|
|
||||||
info.inode = 0;
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
std::rethrow_exception(error);
|
std::rethrow_exception(error);
|
||||||
|
@ -50,6 +50,14 @@ struct StorageFileInfo {
|
|||||||
*/
|
*/
|
||||||
unsigned device, inode;
|
unsigned device, inode;
|
||||||
|
|
||||||
|
StorageFileInfo() = default;
|
||||||
|
|
||||||
|
explicit constexpr StorageFileInfo(Type _type)
|
||||||
|
:type(_type),
|
||||||
|
size(0),
|
||||||
|
mtime(0),
|
||||||
|
device(0), inode(0) {}
|
||||||
|
|
||||||
constexpr bool IsRegular() const {
|
constexpr bool IsRegular() const {
|
||||||
return type == Type::REGULAR;
|
return type == Type::REGULAR;
|
||||||
}
|
}
|
||||||
|
@ -399,11 +399,8 @@ class HttpGetInfoOperation final : public PropfindOperation {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
HttpGetInfoOperation(CurlGlobal &curl, const char *uri)
|
HttpGetInfoOperation(CurlGlobal &curl, const char *uri)
|
||||||
:PropfindOperation(curl, uri, 0) {
|
:PropfindOperation(curl, uri, 0),
|
||||||
info.type = StorageFileInfo::Type::OTHER;
|
info(StorageFileInfo::Type::OTHER) {
|
||||||
info.size = 0;
|
|
||||||
info.mtime = 0;
|
|
||||||
info.device = info.inode = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const StorageFileInfo &Perform() {
|
const StorageFileInfo &Perform() {
|
||||||
@ -424,7 +421,6 @@ protected:
|
|||||||
info.mtime = !IsNegative(r.mtime)
|
info.mtime = !IsNegative(r.mtime)
|
||||||
? std::chrono::system_clock::to_time_t(r.mtime)
|
? std::chrono::system_clock::to_time_t(r.mtime)
|
||||||
: 0;
|
: 0;
|
||||||
info.device = info.inode = 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -514,14 +510,13 @@ protected:
|
|||||||
entries.emplace_front(std::string(name.data, name.size));
|
entries.emplace_front(std::string(name.data, name.size));
|
||||||
|
|
||||||
auto &info = entries.front().info;
|
auto &info = entries.front().info;
|
||||||
info.type = r.collection
|
info = StorageFileInfo(r.collection
|
||||||
? StorageFileInfo::Type::DIRECTORY
|
? StorageFileInfo::Type::DIRECTORY
|
||||||
: StorageFileInfo::Type::REGULAR;
|
: StorageFileInfo::Type::REGULAR);
|
||||||
info.size = r.length;
|
info.size = r.length;
|
||||||
info.mtime = !IsNegative(r.mtime)
|
info.mtime = !IsNegative(r.mtime)
|
||||||
? std::chrono::system_clock::to_time_t(r.mtime)
|
? std::chrono::system_clock::to_time_t(r.mtime)
|
||||||
: 0;
|
: 0;
|
||||||
info.device = info.inode = 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user