Format like smack-a-brother, and write comments as sentences
Four-space indents, braces on their own lines, and one-statement bodies without braces. Semicolons in comments became full stops. Designated initializers may leave fields out without a warning.
This commit is contained in:
1 parent
40f6b554b5
commit
7afdf709c3
176 files changed
+20500
-19048
No files matched your search
+22
-21
@@ -5,41 +5,42 @@
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
|
||||
WorkingDirectory::WorkingDirectory(const std::filesystem::path& path, Type type)
|
||||
{
|
||||
WorkingDirectory::WorkingDirectory(const std::filesystem::path& path, Type type)
|
||||
{
|
||||
std::error_code ec;
|
||||
previous = std::filesystem::current_path(ec);
|
||||
if (ec)
|
||||
{
|
||||
logger.warning(std::format("Could not query current directory: {}", ec.message()));
|
||||
previous.clear();
|
||||
ec.clear();
|
||||
logger.warning(std::format("Could not query current directory: {}", ec.message()));
|
||||
previous.clear();
|
||||
ec.clear();
|
||||
}
|
||||
|
||||
if (type == FILE)
|
||||
{
|
||||
std::filesystem::path filePath = path;
|
||||
std::filesystem::path parentPath = filePath.parent_path();
|
||||
std::filesystem::current_path(parentPath, ec);
|
||||
if (ec)
|
||||
logger.warning(
|
||||
std::format("Could not set current directory to {}: {}", path_to_utf8(parentPath), ec.message()));
|
||||
std::filesystem::path filePath = path;
|
||||
std::filesystem::path parentPath = filePath.parent_path();
|
||||
std::filesystem::current_path(parentPath, ec);
|
||||
if (ec)
|
||||
logger.warning(
|
||||
std::format("Could not set current directory to {}: {}", path_to_utf8(parentPath), ec.message()));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::filesystem::current_path(path, ec);
|
||||
if (ec)
|
||||
logger.warning(std::format("Could not set current directory to {}: {}", path_to_utf8(path), ec.message()));
|
||||
std::filesystem::current_path(path, ec);
|
||||
if (ec)
|
||||
logger.warning(std::format("Could not set current directory to {}: {}", path_to_utf8(path), ec.message()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WorkingDirectory::~WorkingDirectory()
|
||||
{
|
||||
if (previous.empty()) return;
|
||||
WorkingDirectory::~WorkingDirectory()
|
||||
{
|
||||
if (previous.empty())
|
||||
return;
|
||||
|
||||
std::error_code ec;
|
||||
std::filesystem::current_path(previous, ec);
|
||||
if (ec)
|
||||
logger.warning(
|
||||
std::format("Could not restore current directory to {}: {}", path_to_utf8(previous), ec.message()));
|
||||
}
|
||||
logger.warning(
|
||||
std::format("Could not restore current directory to {}: {}", path_to_utf8(previous), ec.message()));
|
||||
}
|
||||
Reference in new issue
Block a user