Code clean up
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
||||
std::string manager::DirectoryManager::createDirectoryProcess(model::Song song, const std::string& rootPath)
|
||||
namespace manager {
|
||||
std::string DirectoryManager::createDirectoryProcess(model::Song song, const std::string& rootPath)
|
||||
{
|
||||
auto currPath = fs::path(rootPath);
|
||||
|
||||
@@ -38,7 +38,7 @@ std::string manager::DirectoryManager::createDirectoryProcess(model::Song song,
|
||||
return albPath.string() + "/";
|
||||
}
|
||||
|
||||
std::string manager::DirectoryManager::createDirectoryProcess(const model::Song& song,
|
||||
std::string DirectoryManager::createDirectoryProcess(const model::Song& song,
|
||||
const model::BinaryPath& bConf, type::PathType pType)
|
||||
{
|
||||
auto path = pathConfigContent(bConf)[retrievePathType(pType)];
|
||||
@@ -71,17 +71,17 @@ std::string manager::DirectoryManager::createDirectoryProcess(const model::Song&
|
||||
return albPath.string() + "/";
|
||||
}
|
||||
|
||||
std::string manager::DirectoryManager::configPath(std::string_view path)
|
||||
std::string DirectoryManager::configPath(std::string_view path)
|
||||
{
|
||||
return fs::canonical(path).parent_path().string();
|
||||
}
|
||||
|
||||
std::string manager::DirectoryManager::configPath(const model::BinaryPath& bConf)
|
||||
std::string DirectoryManager::configPath(const model::BinaryPath& bConf)
|
||||
{
|
||||
return fs::canonical(bConf.path).parent_path().string();
|
||||
}
|
||||
|
||||
std::string manager::DirectoryManager::contentOfPath(const std::string& path)
|
||||
std::string DirectoryManager::contentOfPath(const std::string& path)
|
||||
{
|
||||
std::fstream a(path, std::ios::in);
|
||||
std::stringstream s;
|
||||
@@ -91,7 +91,7 @@ std::string manager::DirectoryManager::contentOfPath(const std::string& path)
|
||||
return s.str();
|
||||
}
|
||||
|
||||
std::string manager::DirectoryManager::retrievePathType(type::PathType pType)
|
||||
std::string DirectoryManager::retrievePathType(type::PathType pType)
|
||||
{
|
||||
std::string path;
|
||||
switch (pType) {
|
||||
@@ -115,7 +115,7 @@ std::string manager::DirectoryManager::retrievePathType(type::PathType pType)
|
||||
}
|
||||
|
||||
|
||||
nlohmann::json manager::DirectoryManager::credentialConfigContent(const model::BinaryPath& bConf)
|
||||
nlohmann::json DirectoryManager::credentialConfigContent(const model::BinaryPath& bConf)
|
||||
{
|
||||
auto path = configPath(bConf);
|
||||
path.append("/authcredentials.json");
|
||||
@@ -123,7 +123,7 @@ nlohmann::json manager::DirectoryManager::credentialConfigContent(const model::B
|
||||
return nlohmann::json::parse(contentOfPath(path));
|
||||
}
|
||||
|
||||
nlohmann::json manager::DirectoryManager::databaseConfigContent(const model::BinaryPath& bConf)
|
||||
nlohmann::json DirectoryManager::databaseConfigContent(const model::BinaryPath& bConf)
|
||||
{
|
||||
auto path = configPath(bConf);
|
||||
path.append("/database.json");
|
||||
@@ -131,7 +131,7 @@ nlohmann::json manager::DirectoryManager::databaseConfigContent(const model::Bin
|
||||
return nlohmann::json::parse(contentOfPath(path));
|
||||
}
|
||||
|
||||
nlohmann::json manager::DirectoryManager::pathConfigContent(const model::BinaryPath& bConf)
|
||||
nlohmann::json DirectoryManager::pathConfigContent(const model::BinaryPath& bConf)
|
||||
{
|
||||
auto path = configPath(bConf);
|
||||
path.append("/paths.json");
|
||||
@@ -139,7 +139,8 @@ nlohmann::json manager::DirectoryManager::pathConfigContent(const model::BinaryP
|
||||
return nlohmann::json::parse(contentOfPath(path));
|
||||
}
|
||||
|
||||
void manager::DirectoryManager::deleteDirectories(model::Song song, const std::string& rootPath)
|
||||
|
||||
void DirectoryManager::deleteDirectories(model::Song song, const std::string& rootPath)
|
||||
{
|
||||
std::cout << "checking for empty directories to delete" << std::endl;
|
||||
const std::string art(rootPath + std::string("/") + song.artist);
|
||||
@@ -165,7 +166,8 @@ void manager::DirectoryManager::deleteDirectories(model::Song song, const std::s
|
||||
std::cout << "deleted empty directory or directories" << std::endl;
|
||||
}
|
||||
|
||||
void manager::DirectoryManager::deleteCoverArtFile(const std::string& covPath, const std::string& stockCoverPath)
|
||||
void DirectoryManager::deleteCoverArtFile(const std::string& covPath,
|
||||
const std::string& stockCoverPath)
|
||||
{
|
||||
if (covPath.compare(stockCoverPath) == 0) {
|
||||
std::cout << "cover has stock cover art, will not deleted" << std::endl;
|
||||
@@ -176,7 +178,7 @@ void manager::DirectoryManager::deleteCoverArtFile(const std::string& covPath, c
|
||||
}
|
||||
}
|
||||
|
||||
void manager::DirectoryManager::deleteSong(const model::Song song)
|
||||
void DirectoryManager::deleteSong(const model::Song song)
|
||||
{
|
||||
std::cout << "deleting song" << std::endl;
|
||||
auto songPath = fs::path(song.songPath);
|
||||
@@ -190,3 +192,4 @@ void manager::DirectoryManager::deleteSong(const model::Song song)
|
||||
std::cout << "deleted song" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user