mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 22:05:38 +00:00
First review code changes (identation and cosmetic changes)
This commit is contained in:
parent
d11efb8553
commit
317f8bacde
|
@ -32,9 +32,9 @@
|
||||||
|
|
||||||
namespace FileSystemPath
|
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)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,45 +45,45 @@ namespace FileSystemPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates a path to be used by Supermodel files
|
// Generates a path to be used by Supermodel files
|
||||||
std::string GetPath(fsPathType pathType)
|
std::string GetPath(PathType pathType)
|
||||||
{
|
{
|
||||||
std::string finalPath = "";
|
std::string finalPath = "";
|
||||||
std::string homePath = "";
|
std::string homePath = "";
|
||||||
std::string strPathType = "";
|
std::string strPathType = "";
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
|
|
||||||
// Resolve pathType to string for later use
|
// Resolve pathType to string for later use
|
||||||
switch (pathType)
|
switch (pathType)
|
||||||
{
|
{
|
||||||
case Analysis:
|
case Analysis:
|
||||||
strPathType = "Analysis";
|
strPathType = "Analysis";
|
||||||
break;
|
break;
|
||||||
case Config:
|
case Config:
|
||||||
strPathType = "Config";
|
strPathType = "Config";
|
||||||
break;
|
break;
|
||||||
case Log:
|
case Log:
|
||||||
strPathType = "Log";
|
strPathType = "Log";
|
||||||
break;
|
break;
|
||||||
case NVRAM:
|
case NVRAM:
|
||||||
strPathType = "NVRAM";
|
strPathType = "NVRAM";
|
||||||
break;
|
break;
|
||||||
case Saves:
|
case Saves:
|
||||||
strPathType = "Saves";
|
strPathType = "Saves";
|
||||||
break;
|
break;
|
||||||
case Screenshots:
|
case Screenshots:
|
||||||
strPathType = "Screenshots";
|
strPathType = "Screenshots";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user's HOME directory
|
// Get user's HOME directory
|
||||||
if (pwd)
|
if (pwd)
|
||||||
{
|
{
|
||||||
homePath = pwd->pw_dir;
|
homePath = pwd->pw_dir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
homePath = getenv("HOME");
|
homePath = getenv("HOME");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Config path exists in current directory or the user doesn't have a HOME directory use current directory
|
// 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())
|
if (FileSystemPath::PathExists("Config") || homePath.empty())
|
||||||
|
@ -96,10 +96,12 @@ namespace FileSystemPath
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If directory doesn't exist, create it
|
// 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;
|
finalPath = strPathType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Check if $HOME/.supermodel exists
|
// Check if $HOME/.supermodel exists
|
||||||
else if (FileSystemPath::PathExists(Util::Format() << homePath << "/.supermodel"))
|
else if (FileSystemPath::PathExists(Util::Format() << homePath << "/.supermodel"))
|
||||||
|
@ -120,25 +122,39 @@ namespace FileSystemPath
|
||||||
{
|
{
|
||||||
finalPath = Util::Format() << homePath << "/.config/supermodel";
|
finalPath = Util::Format() << homePath << "/.config/supermodel";
|
||||||
// If directory doesn't exist, create it
|
// 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
|
// If directory doesn't exist, create it
|
||||||
finalPath = Util::Format() << homePath << "/.config/supermodel/Config";
|
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
|
else
|
||||||
{
|
{
|
||||||
finalPath = Util::Format() << homePath << "/.local/share/supermodel";
|
finalPath = Util::Format() << homePath << "/.local/share/supermodel";
|
||||||
// If directory doesn't exist, create it
|
// 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
|
// If directory doesn't exist, create it
|
||||||
finalPath = Util::Format() << homePath << "/.local/share/supermodel/" << strPathType;
|
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;
|
return finalPath;
|
||||||
|
|
||||||
|
|
|
@ -25,22 +25,22 @@
|
||||||
namespace FileSystemPath
|
namespace FileSystemPath
|
||||||
{
|
{
|
||||||
// Generates a path to be used by Supermodel files
|
// Generates a path to be used by Supermodel files
|
||||||
std::string GetPath(fsPathType pathType)
|
std::string GetPath(PathType pathType)
|
||||||
{
|
{
|
||||||
switch (pathType)
|
switch (pathType)
|
||||||
{
|
{
|
||||||
case Analysis:
|
case Analysis:
|
||||||
return "Analysis/";
|
return "Analysis/";
|
||||||
case Config:
|
case Config:
|
||||||
return "Config/";
|
return "Config/";
|
||||||
case Log:
|
case Log:
|
||||||
return "";
|
return "";
|
||||||
case NVRAM:
|
case NVRAM:
|
||||||
return "NVRAM/";
|
return "NVRAM/";
|
||||||
case Saves:
|
case Saves:
|
||||||
return "Saves/";
|
return "Saves/";
|
||||||
case Screenshots:
|
case Screenshots:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue