[ox/fs] Add FileAddress::operator==(FileAddress)
This commit is contained in:
26
deps/ox/src/ox/fs/filesystem/filelocation.cpp
vendored
26
deps/ox/src/ox/fs/filesystem/filelocation.cpp
vendored
@@ -88,6 +88,32 @@ FileAddress &FileAddress::operator=(FileAddress &&other) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool FileAddress::operator==(FileAddress const&other) const noexcept {
|
||||
if (m_type != other.m_type) {
|
||||
auto const aIsPath =
|
||||
m_type == FileAddressType::Path || m_type == FileAddressType::ConstPath;
|
||||
auto const bIsPath =
|
||||
other.m_type == FileAddressType::Path || other.m_type == FileAddressType::ConstPath;
|
||||
if (!(aIsPath && bIsPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
switch (m_type) {
|
||||
case FileAddressType::ConstPath:
|
||||
case FileAddressType::Path: {
|
||||
auto const a = getPath();
|
||||
auto const b = other.getPath();
|
||||
return (other.m_type == FileAddressType::ConstPath || other.m_type == FileAddressType::Path)
|
||||
&& (a.value == b.value);
|
||||
}
|
||||
case FileAddressType::Inode:
|
||||
return m_data.inode == other.m_data.inode;
|
||||
case FileAddressType::None:
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileAddress::operator==(CRStringView path) const noexcept {
|
||||
auto [p, err] = getPath();
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user