From 317f8bacde218f529f3107643af5cb3986ba4729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Casas=20Sch=C3=B6ssow?= Date: Mon, 21 Nov 2022 22:27:15 +0100 Subject: [PATCH] First review code changes (identation and cosmetic changes) --- Src/OSD/FileSystemPath.h | 4 +- Src/OSD/Unix/FileSystemPath.cpp | 88 ++++++++++++++++++------------ Src/OSD/Windows/FileSystemPath.cpp | 26 ++++----- 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/Src/OSD/FileSystemPath.h b/Src/OSD/FileSystemPath.h index b192f2b..3c04b62 100644 --- a/Src/OSD/FileSystemPath.h +++ b/Src/OSD/FileSystemPath.h @@ -32,9 +32,9 @@ namespace FileSystemPath { - enum fsPathType { Analysis, Config, Log, NVRAM, Saves, Screenshots }; // Filesystem path types + enum PathType { Analysis, Config, Log, NVRAM, Saves, Screenshots }; // Filesystem path types bool PathExists(std::string fileSystemPath); // Checks if a directory exists (returns true if exists, false if it doesn't) - std::string GetPath(fsPathType pathType); // Generates a path to be used by Supermodel files + std::string GetPath(PathType pathType); // Generates a path to be used by Supermodel files } diff --git a/Src/OSD/Unix/FileSystemPath.cpp b/Src/OSD/Unix/FileSystemPath.cpp index ce899fe..4ab5916 100644 --- a/Src/OSD/Unix/FileSystemPath.cpp +++ b/Src/OSD/Unix/FileSystemPath.cpp @@ -45,45 +45,45 @@ namespace FileSystemPath } // Generates a path to be used by Supermodel files - std::string GetPath(fsPathType pathType) + std::string GetPath(PathType pathType) { std::string finalPath = ""; std::string homePath = ""; std::string strPathType = ""; - struct passwd* pwd = getpwuid(getuid()); + struct passwd* pwd = getpwuid(getuid()); // Resolve pathType to string for later use switch (pathType) { - case Analysis: - strPathType = "Analysis"; - break; - case Config: - strPathType = "Config"; - break; - case Log: - strPathType = "Log"; - break; - case NVRAM: - strPathType = "NVRAM"; - break; - case Saves: - strPathType = "Saves"; - break; - case Screenshots: - strPathType = "Screenshots"; - break; + case Analysis: + strPathType = "Analysis"; + break; + case Config: + strPathType = "Config"; + break; + case Log: + strPathType = "Log"; + break; + case NVRAM: + strPathType = "NVRAM"; + break; + case Saves: + strPathType = "Saves"; + break; + case Screenshots: + strPathType = "Screenshots"; + break; } // Get user's HOME directory - if (pwd) - { - homePath = pwd->pw_dir; - } - else - { - homePath = getenv("HOME"); - } + if (pwd) + { + homePath = pwd->pw_dir; + } + else + { + homePath = getenv("HOME"); + } // If Config path exists in current directory or the user doesn't have a HOME directory use current directory if (FileSystemPath::PathExists("Config") || homePath.empty()) @@ -96,10 +96,12 @@ namespace FileSystemPath else { // If directory doesn't exist, create it - if (!FileSystemPath::PathExists(strPathType)) mkdir(strPathType.c_str(), 0775); + if (!FileSystemPath::PathExists(strPathType)) + { + mkdir(strPathType.c_str(), 0775); + } finalPath = strPathType; } - } // Check if $HOME/.supermodel exists else if (FileSystemPath::PathExists(Util::Format() << homePath << "/.supermodel")) @@ -120,25 +122,39 @@ namespace FileSystemPath { finalPath = Util::Format() << homePath << "/.config/supermodel"; // If directory doesn't exist, create it - if (!FileSystemPath::PathExists(finalPath)) mkdir(finalPath.c_str(), 0775); + if (!FileSystemPath::PathExists(finalPath)) + { + mkdir(finalPath.c_str(), 0775); + } // If directory doesn't exist, create it finalPath = Util::Format() << homePath << "/.config/supermodel/Config"; - if (!FileSystemPath::PathExists(finalPath)) mkdir(finalPath.c_str(), 0775); - + if (!FileSystemPath::PathExists(finalPath)) + { + mkdir(finalPath.c_str(), 0775); + } } else { finalPath = Util::Format() << homePath << "/.local/share/supermodel"; // If directory doesn't exist, create it - if (!FileSystemPath::PathExists(finalPath)) mkdir(finalPath.c_str(), 0775); + if (!FileSystemPath::PathExists(finalPath)) + { + mkdir(finalPath.c_str(), 0775); + } // If directory doesn't exist, create it finalPath = Util::Format() << homePath << "/.local/share/supermodel/" << strPathType; - if (!FileSystemPath::PathExists(finalPath)) mkdir(finalPath.c_str(), 0775); + if (!FileSystemPath::PathExists(finalPath)) + { + mkdir(finalPath.c_str(), 0775); + } } } - if (finalPath != "") finalPath = Util::Format() << finalPath << "/"; + if (finalPath != "") + { + finalPath = Util::Format() << finalPath << "/"; + } return finalPath; diff --git a/Src/OSD/Windows/FileSystemPath.cpp b/Src/OSD/Windows/FileSystemPath.cpp index 4390730..9536d27 100644 --- a/Src/OSD/Windows/FileSystemPath.cpp +++ b/Src/OSD/Windows/FileSystemPath.cpp @@ -25,22 +25,22 @@ namespace FileSystemPath { // Generates a path to be used by Supermodel files - std::string GetPath(fsPathType pathType) + std::string GetPath(PathType pathType) { switch (pathType) { - case Analysis: - return "Analysis/"; - case Config: - return "Config/"; - case Log: - return ""; - case NVRAM: - return "NVRAM/"; - case Saves: - return "Saves/"; - case Screenshots: - return ""; + case Analysis: + return "Analysis/"; + case Config: + return "Config/"; + case Log: + return ""; + case NVRAM: + return "NVRAM/"; + case Saves: + return "Saves/"; + case Screenshots: + return ""; } } }