mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
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
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user