diff options
author | Oleksiy Vyalov <ovyalov@google.com> | 2015-04-15 14:35:10 +0000 |
---|---|---|
committer | Oleksiy Vyalov <ovyalov@google.com> | 2015-04-15 14:35:10 +0000 |
commit | 280d8dc9f06989dea6b304d780f43e522146a6eb (patch) | |
tree | e917ca474ce2678be6b6ee4ec0b7d7d3f23c72fb /lldb/source/Utility/ModuleCache.cpp | |
parent | 3c886e6efcd3de03a2851f59d062176fe5c39e96 (diff) | |
download | bcm5719-llvm-280d8dc9f06989dea6b304d780f43e522146a6eb.tar.gz bcm5719-llvm-280d8dc9f06989dea6b304d780f43e522146a6eb.zip |
Add Modulecache::GetAndPut method which wraps sequence of Get and Put (if module wasn't found in cache) calls.
http://reviews.llvm.org/D9013
llvm-svn: 235011
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) { |