Probe app dir relative asset rel path

This commit is contained in:
Senthil 2016-03-25 13:26:08 -07:00
parent 01dda26a6f
commit b82c998614
3 changed files with 47 additions and 11 deletions

View file

@ -6,6 +6,7 @@
#include "deps_entry.h" #include "deps_entry.h"
#include "trace.h" #include "trace.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Given a "base" directory, yield the relative path of this file in the package // Given a "base" directory, yield the relative path of this file in the package
// layout. // layout.
@ -18,7 +19,7 @@
// Returns: // Returns:
// If the file exists in the path relative to the "base" directory. // If the file exists in the path relative to the "base" directory.
// //
bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const bool deps_entry_t::to_rel_path(const pal::string_t& base, pal::string_t* str) const
{ {
pal::string_t& candidate = *str; pal::string_t& candidate = *str;
@ -40,23 +41,53 @@ bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) c
// Reserve space for the path below // Reserve space for the path below
candidate.reserve(base.length() + candidate.reserve(base.length() +
library_name.length() +
library_version.length() +
pal_relative_path.length() + 3); pal_relative_path.length() + 3);
candidate.assign(base); candidate.assign(base);
append_path(&candidate, library_name.c_str());
append_path(&candidate, library_version.c_str());
append_path(&candidate, pal_relative_path.c_str()); append_path(&candidate, pal_relative_path.c_str());
bool exists = pal::file_exists(candidate); bool exists = pal::file_exists(candidate);
if (!exists) if (!exists)
{ {
trace::verbose(_X("Relative path query did not exist %s"), candidate.c_str());
candidate.clear(); candidate.clear();
} }
else
{
trace::verbose(_X("Relative path query exists %s"), candidate.c_str());
}
return exists; return exists;
} }
// -----------------------------------------------------------------------------
// 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 relative to the "base" directory
//
// Returns:
// If the file exists in the path relative to the "base" directory.
//
bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const
{
str->clear();
// Base directory must be present to obtain full path
if (base.empty())
{
return false;
}
pal::string_t new_base = base;
append_path(&new_base, library_name.c_str());
append_path(&new_base, library_version.c_str());
return to_rel_path(new_base, str);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Given a "base" directory, yield the relative path of this file in the package // Given a "base" directory, yield the relative path of this file in the package
// layout if the entry hash matches the hash file in the "base" directory // layout if the entry hash matches the hash file in the "base" directory

View file

@ -28,9 +28,12 @@ struct deps_entry_t
bool is_serviceable; bool is_serviceable;
// Given a "base" dir, yield the relative path in the package layout. // Given a "base" dir, yield the relative path in the package layout.
bool to_rel_path(const pal::string_t& base, pal::string_t* str) const;
// Given a "base" dir, yield the relative path with package name, version in the package layout.
bool to_full_path(const pal::string_t& root, pal::string_t* str) const; bool to_full_path(const pal::string_t& root, pal::string_t* str) const;
// Given a "base" dir, yield the relative path in the package layout only if // Given a "base" dir, yield the relative path with package name, version in the package layout only if
// the hash matches contents of the hash file. // the hash matches contents of the hash file.
bool to_hash_matched_path(const pal::string_t& root, pal::string_t* str) const; bool to_hash_matched_path(const pal::string_t& root, pal::string_t* str) const;
}; };

View file

@ -286,6 +286,8 @@ void deps_resolver_t::resolve_tpa_list(
pal::string_t candidate; pal::string_t candidate;
trace::info(_X("Processing TPA for deps entry [%s, %s, %s]"), entry.library_name.c_str(), entry.library_version.c_str(), entry.relative_path.c_str());
// Is this a serviceable entry and is there an entry in the servicing index? // Is this a serviceable entry and is there an entry in the servicing index?
if (entry.is_serviceable && entry.library_type == _X("Package") && if (entry.is_serviceable && entry.library_type == _X("Package") &&
m_svc.find_redirection(entry.library_name, entry.library_version, entry.relative_path, &candidate)) m_svc.find_redirection(entry.library_name, entry.library_version, entry.relative_path, &candidate))
@ -303,7 +305,7 @@ void deps_resolver_t::resolve_tpa_list(
add_tpa_asset(entry.asset_name, candidate, &items, output); add_tpa_asset(entry.asset_name, candidate, &items, output);
} }
// The app is portable so the rid asset should be picked up from relative subpath. // The app is portable so the rid asset should be picked up from relative subpath.
else if (is_portable && deps->try_ni(entry).to_full_path(app_dir, &candidate)) else if (is_portable && deps->try_ni(entry).to_rel_path(app_dir, &candidate))
{ {
add_tpa_asset(entry.asset_name, candidate, &items, output); add_tpa_asset(entry.asset_name, candidate, &items, output);
} }
@ -421,21 +423,21 @@ void deps_resolver_t::resolve_probe_dirs(
std::for_each(fx_entries.begin(), fx_entries.end(), add_package_cache_entry); std::for_each(fx_entries.begin(), fx_entries.end(), add_package_cache_entry);
} }
// App local path
add_unique_path(asset_type, app_dir, &items, output);
// For portable path, the app relative directory must be used. // For portable path, the app relative directory must be used.
if (m_portable) if (m_portable)
{ {
std::for_each(entries.begin(), entries.end(), [&](const deps_entry_t& entry) std::for_each(entries.begin(), entries.end(), [&](const deps_entry_t& entry)
{ {
if (entry.asset_type == asset_type && entry.to_full_path(package_dir, &candidate)) if (entry.asset_type == asset_type && entry.to_rel_path(app_dir, &candidate))
{ {
add_unique_path(asset_type, action(candidate), &items, output); add_unique_path(asset_type, action(candidate), &items, output);
} }
}); });
} }
// App local path
add_unique_path(asset_type, app_dir, &items, output);
// FX path if present // FX path if present
if (!m_fx_dir.empty()) if (!m_fx_dir.empty())
{ {