Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/installer/corehost/cli/deps_entry.cpp')
-rw-r--r--src/installer/corehost/cli/deps_entry.cpp118
1 files changed, 36 insertions, 82 deletions
diff --git a/src/installer/corehost/cli/deps_entry.cpp b/src/installer/corehost/cli/deps_entry.cpp
index 449403fa038..08d196c1741 100644
--- a/src/installer/corehost/cli/deps_entry.cpp
+++ b/src/installer/corehost/cli/deps_entry.cpp
@@ -6,39 +6,9 @@
#include "utils.h"
#include "deps_entry.h"
#include "trace.h"
-#include "bundle/runner.h"
-static pal::string_t normalize_dir_separator(const pal::string_t& path)
-{
- // Entry relative path contains '/' separator, sanitize it to use
- // platform separator. Perf: avoid extra copy if it matters.
- pal::string_t normalized_path = path;
- if (_X('/') != DIR_SEPARATOR)
- {
- replace_char(&normalized_path, _X('/'), DIR_SEPARATOR);
- }
-
- return normalized_path;
-}
-// -----------------------------------------------------------------------------
-// Given a "base" directory, determine the resolved path for this file.
-//
-// * If this file exists within the single-file bundle candidate is
-// the full-path to the extracted file.
-// * Otherwise, candidate is the full local path of the file.
-//
-// Parameters:
-// base - The base directory to look for the relative path of this entry
-// ietf_dir - If this is a resource asset, the IETF intermediate directory
-// look_in_base - Whether to search as a relative path
-// look_in_bundle - Whether to look within the single-file bundle
-// str - If the method returns true, contains the file path for this deps entry
-//
-// Returns:
-// If the file exists in the path relative to the "base" directory within the
-// single-file or on disk.
-bool deps_entry_t::to_path(const pal::string_t& base, const pal::string_t& ietf_dir, bool look_in_base, bool look_in_bundle, pal::string_t* str) const
+bool deps_entry_t::to_path(const pal::string_t& base, bool look_in_base, pal::string_t* str) const
{
pal::string_t& candidate = *str;
@@ -50,41 +20,20 @@ bool deps_entry_t::to_path(const pal::string_t& base, const pal::string_t& ietf_
return false;
}
- pal::string_t normalized_path = normalize_dir_separator(asset.relative_path);
-
- // Reserve space for the path below
- candidate.reserve(base.length() + ietf_dir.length() + normalized_path.length() + 3);
-
- pal::string_t file_path = look_in_base ? get_filename(normalized_path) : normalized_path;
- pal::string_t sub_path = ietf_dir;
- append_path(&sub_path, file_path.c_str());
-
- if (look_in_bundle && bundle::info_t::is_single_file_bundle())
+ // Entry relative path contains '/' separator, sanitize it to use
+ // platform separator. Perf: avoid extra copy if it matters.
+ pal::string_t pal_relative_path = asset.relative_path;
+ if (_X('/') != DIR_SEPARATOR)
{
- const bundle::runner_t* app = bundle::runner_t::app();
-
- if (base.compare(app->base_path()) == 0)
- {
- // If sub_path is found in the single-file bundle,
- // app::locate() will set candidate to the full-path to the assembly extracted out to disk.
- if (app->locate(sub_path, candidate))
- {
- trace::verbose(_X(" %s found in bundle [%s]"), sub_path.c_str(), candidate.c_str());
- return true;
- }
- else
- {
- trace::verbose(_X(" %s not found in bundle"), sub_path.c_str());
- }
- }
- else
- {
- trace::verbose(_X(" %s not searched in bundle base path %s doesn't match bundle base %s."),
- sub_path.c_str(), base.c_str(), app->base_path().c_str());
- }
+ replace_char(&pal_relative_path, _X('/'), DIR_SEPARATOR);
}
+ // Reserve space for the path below
+ candidate.reserve(base.length() +
+ pal_relative_path.length() + 3);
+
candidate.assign(base);
+ pal::string_t sub_path = look_in_base ? get_filename(pal_relative_path) : pal_relative_path;
append_path(&candidate, sub_path.c_str());
bool exists = pal::file_exists(candidate);
@@ -98,7 +47,6 @@ bool deps_entry_t::to_path(const pal::string_t& base, const pal::string_t& ietf_
{
trace::verbose(_X(" %s path query exists %s"), query_type, candidate.c_str());
}
-
return exists;
}
@@ -107,50 +55,55 @@ bool deps_entry_t::to_path(const pal::string_t& base, const pal::string_t& ietf_
//
// Parameters:
// base - The base directory to look for the relative path of this entry
-// str - If the method returns true, contains the file path for this deps entry
+// str - If the method returns true, contains the file path for this deps
+// entry relative to the "base" directory
//
// Returns:
// If the file exists in the path relative to the "base" directory.
//
-bool deps_entry_t::to_dir_path(const pal::string_t& base, bool look_in_bundle, pal::string_t* str) const
+bool deps_entry_t::to_dir_path(const pal::string_t& base, pal::string_t* str) const
{
- pal::string_t ietf_dir;
-
if (asset_type == asset_types::resources)
{
- pal::string_t pal_relative_path = normalize_dir_separator(asset.relative_path);
+ pal::string_t pal_relative_path = asset.relative_path;
+ if (_X('/') != DIR_SEPARATOR)
+ {
+ replace_char(&pal_relative_path, _X('/'), DIR_SEPARATOR);
+ }
// Resources are represented as "lib/<netstandrd_ver>/<ietf-code>/<ResourceAssemblyName.dll>" in the deps.json.
// The <ietf-code> is the "directory" in the pal_relative_path below, so extract it.
- ietf_dir = get_directory(pal_relative_path);
+ pal::string_t ietf_dir = get_directory(pal_relative_path);
+ pal::string_t ietf = ietf_dir;
// get_directory returns with DIR_SEPARATOR appended that we need to remove.
- remove_trailing_dir_seperator(&ietf_dir);
+ remove_trailing_dir_seperator(&ietf);
// Extract IETF code from "lib/<netstandrd_ver>/<ietf-code>"
- ietf_dir = get_filename(ietf_dir);
-
- trace::verbose(_X("Detected a resource asset, will query dir/ietf-tag/resource base: %s ietf: %s asset: %s"),
- base.c_str(), ietf_dir.c_str(), asset.name.c_str());
+ ietf = get_filename(ietf);
+
+ pal::string_t base_ietf_dir = base;
+ append_path(&base_ietf_dir, ietf.c_str());
+ trace::verbose(_X("Detected a resource asset, will query dir/ietf-tag/resource base: %s asset: %s"), base_ietf_dir.c_str(), asset.name.c_str());
+ return to_path(base_ietf_dir, true, str);
}
-
- return to_path(base, ietf_dir, true, look_in_bundle, str);
+ return to_path(base, true, str);
}
-
// -----------------------------------------------------------------------------
// Given a "base" directory, yield the relative path of this file in the package
// layout.
//
// Parameters:
// base - The base directory to look for the relative path of this entry
-// str - If the method returns true, contains the file path for this deps entry
+// str - If the method returns true, contains the file path for this deps
+// entry relative to the "base" directory
//
// Returns:
// If the file exists in the path relative to the "base" directory.
//
-bool deps_entry_t::to_rel_path(const pal::string_t& base, bool look_in_bundle, pal::string_t* str) const
+bool deps_entry_t::to_rel_path(const pal::string_t& base, pal::string_t* str) const
{
- return to_path(base, _X(""), false, look_in_bundle, str);
+ return to_path(base, false, str);
}
// -----------------------------------------------------------------------------
@@ -159,7 +112,8 @@ bool deps_entry_t::to_rel_path(const pal::string_t& base, bool look_in_bundle, p
//
// Parameters:
// base - The base directory to look for the relative path of this entry
-// str - If the method returns true, contains the file path for this deps entry
+// str - If the method returns true, contains the file path for this deps
+// entry relative to the "base" directory
//
// Returns:
// If the file exists in the path relative to the "base" directory.
@@ -186,5 +140,5 @@ bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) c
append_path(&new_base, library_path.c_str());
}
- return to_rel_path(new_base, false, str);
+ return to_rel_path(new_base, str);
}