summaryrefslogtreecommitdiff
path: root/source/fud_directory.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-03 08:07:05 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-03 08:07:05 -0500
commite420eca2b244c303af51534ab09632045a186b21 (patch)
treeba4ec2d6863b716672f35898266516b58c727aa9 /source/fud_directory.cpp
parent97bbafb762defc01abc38834b70a7e8f20d654f5 (diff)
Cleanup from clang-tidy.
Diffstat (limited to 'source/fud_directory.cpp')
-rw-r--r--source/fud_directory.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/source/fud_directory.cpp b/source/fud_directory.cpp
index 5772c95..1fcebe1 100644
--- a/source/fud_directory.cpp
+++ b/source/fud_directory.cpp
@@ -41,11 +41,10 @@ Result<DirectoryEntry, FudStatus> DirectoryEntry::fromStat(const String& name, c
size_t size{0};
if (statBuffer.st_size < 0) {
return RetType::error(FudStatus::Failure);
- } else {
- size = static_cast<size_t>(statBuffer.st_size);
}
+ size = static_cast<size_t>(statBuffer.st_size);
- DirectoryEntryType entryType;
+ DirectoryEntryType entryType{};
switch (statBuffer.st_mode & S_IFMT) {
case S_IFBLK:
entryType = DirectoryEntryType::Block;
@@ -73,11 +72,16 @@ Result<DirectoryEntry, FudStatus> DirectoryEntry::fromStat(const String& name, c
break;
}
- return RetType::okay(
- DirectoryEntry{name, statBuffer.st_ino, size, static_cast<size_t>(statBuffer.st_nlink), statBuffer.st_mtime, entryType});
+ return RetType::okay(DirectoryEntry{
+ name,
+ statBuffer.st_ino,
+ size,
+ static_cast<size_t>(statBuffer.st_nlink),
+ statBuffer.st_mtime,
+ entryType});
}
-Directory::Directory(String name) : m_name{name}
+Directory::Directory(const String& name) : m_name{name}
{
if (!m_name.valid()) {
return;
@@ -108,7 +112,7 @@ Directory::Directory(String name) : m_name{name}
m_status = FudStatus::Success;
}
-Directory::Directory(Directory&& rhs) :
+Directory::Directory(Directory&& rhs) noexcept :
m_name{std::move(rhs.m_name)}, m_directory{rhs.m_directory}, m_dirFd{rhs.m_dirFd}
{
rhs.m_directory = nullptr;
@@ -173,9 +177,8 @@ Result<std::optional<DirectoryEntry>, FudStatus> Directory::getNextEntry()
m_errorCode = errno;
m_status = FudStatus::Failure;
return RetType::error(m_status);
- } else {
- return RetType::okay(std::nullopt);
}
+ return RetType::okay(std::nullopt);
}
const char* entryNameCString = dirEntry->d_name;
@@ -202,7 +205,7 @@ Result<std::optional<DirectoryEntry>, FudStatus> Directory::getNextEntry()
if (retValue.isOkay()) {
m_errorCode = 0;
m_status = FudStatus::Success;
- return RetType::okay(retValue.getOkay());
+ return RetType::okay(std::move(retValue.getOkay()));
}
m_status = retValue.getError();