diff options
Diffstat (limited to 'lldb/source/Utility/ModuleCache.cpp')
-rw-r--r-- | lldb/source/Utility/ModuleCache.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lldb/source/Utility/ModuleCache.cpp b/lldb/source/Utility/ModuleCache.cpp index 41b99bb3f96..095a4c76cae 100644 --- a/lldb/source/Utility/ModuleCache.cpp +++ b/lldb/source/Utility/ModuleCache.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/FileSystem.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/FileUtilities.h" #include <assert.h> @@ -118,6 +119,44 @@ ModuleCache::Get (const FileSpec &root_dir_spec, return Error (); } +Error +ModuleCache::GetAndPut (const FileSpec &root_dir_spec, + const char *hostname, + const ModuleSpec &module_spec, + const Downloader &downloader, + lldb::ModuleSP &cached_module_sp, + bool *did_create_ptr) +{ + // Check local cache for a module. + auto error = Get (root_dir_spec, + hostname, + module_spec, + cached_module_sp, + did_create_ptr); + if (error.Success ()) + return error; + + FileSpec tmp_download_file_spec; + error = downloader (module_spec, tmp_download_file_spec); + llvm::FileRemover tmp_file_remover (tmp_download_file_spec.GetPath ().c_str ()); + if (error.Fail ()) + return Error("Failed to download module: %s", error.AsCString ()); + + // Put downloaded file into local module cache. + error = Put (root_dir_spec, + hostname, + module_spec, + tmp_download_file_spec); + if (error.Fail ()) + return Error ("Failed to put module into cache: %s", error.AsCString ()); + + return Get (root_dir_spec, + hostname, + module_spec, + cached_module_sp, + did_create_ptr); +} + FileSpec ModuleCache::GetModuleDirectory (const FileSpec &root_dir_spec, const UUID &uuid) { |