aboutsummaryrefslogtreecommitdiff
path: root/src/GlobalLib.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-12 19:46:57 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-12 19:49:29 +0100
commitf2c70dfaba8d6481e86646080c51b6874d95f14e (patch)
tree1ee19bdd5f951b86f2b481c94f969a473a5e57fc /src/GlobalLib.cpp
parentf3b7b7d34b3bf2b1be18914577c96b66dead379a (diff)
Lazily create directories that are needed
Directories such as: ~/.sibs ~/.sibs/archive ~/.sibs/lib And directories for each specific library. Also fix bug in getFileContent and fileOverwrite if file already exists
Diffstat (limited to 'src/GlobalLib.cpp')
-rw-r--r--src/GlobalLib.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp
index ce9426d..177f1b9 100644
--- a/src/GlobalLib.cpp
+++ b/src/GlobalLib.cpp
@@ -140,8 +140,11 @@ namespace sibs
}
else
{
- // TODO: Create build path if it doesn't exist
string debugBuildPath = packageDir + "/build/debug";
+ Result<bool> createBuildDirResult = createDirectoryRecursive(debugBuildPath.c_str());
+ if(createBuildDirResult.isErr())
+ return Result<string>::Err(createBuildDirResult);
+
Result<bool> buildFileResult = ninja.createBuildFile(sibsConfig.getPackageName(), sibsConfig.getDependencies(), debugBuildPath.c_str(), linkerFlagCallbackFunc);
if (buildFileResult.isErr())
return Result<string>::Err(buildFileResult.getErrMsg());
@@ -167,23 +170,30 @@ namespace sibs
url += dependency.version;
url += ".tar.gz";
- // TODO: Create library path if it doesn't exist
string libPath = getHomeDir();
libPath += "/.sibs/lib/";
libPath += dependency.name;
libPath += "/";
libPath += dependency.version;
- // TODO: Create archive directory if it doesn't exist
string libArchivedFilePath = getHomeDir();
libArchivedFilePath += "/.sibs/archive/";
libArchivedFilePath += dependency.name;
+ Result<bool> createArchiveDirResult = createDirectoryRecursive(libArchivedFilePath.c_str());
+ if(createArchiveDirResult.isErr())
+ return createArchiveDirResult;
+
libArchivedFilePath += "/";
libArchivedFilePath += dependency.version;
Result<bool> downloadResult = curl::downloadFile(url.c_str(), libArchivedFilePath.c_str());
if(downloadResult.isErr())
return downloadResult;
+ // Create build path. This is done here because we dont want to create it if download fails
+ Result<bool> createLibDirResult = createDirectoryRecursive(libPath.c_str());
+ if(createLibDirResult.isErr())
+ return createLibDirResult;
+
return Archive::extract(libArchivedFilePath.c_str(), libPath.c_str());
}
} \ No newline at end of file