Skip to content

Commit

Permalink
Revert "OrcLib: LocationSet: expand Orc variable '{ProfileDirectory}'"
Browse files Browse the repository at this point in the history
This reverts commit 375ecab.

ProfileDirectory is resolved as the configured directory but older profiles
may be stored elsewhere. This revert has the purpose of avoiding any
missuse.
  • Loading branch information
fabienfl-orc committed Sep 25, 2020
1 parent 332a1a6 commit 8beebc9
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions src/OrcLib/LocationSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,6 @@ using namespace Orc;

namespace {

stx::Result<std::wstring, HRESULT> GetProfilesDirectory()
{
// Logger is not used here and will be remove in 10.1.x
return ProfileList::ProfilesDirectory({});
}

std::wstring ExpandOrcStrings(const std::wstring& raw, const Orc::logger& pLog)
{
using Handler = std::function<stx::Result<std::wstring, HRESULT>()>;

// TODO: eventually cache the results, a better choice may be to Expand once
const std::unordered_map<std::wstring, Handler> convertors = {{L"{ProfilesDirectory}", GetProfilesDirectory}};

auto out = raw;
for (const auto& [key, convertor] : convertors)
{
if (!boost::icontains(key, out))
{
continue;
}

auto result = convertor();
if (!result)
{
log::Error(pLog, E_FAIL, L"Failed to expand orc variable: '%s'", key);
continue;
}

boost::ireplace_all<std::wstring>(out, key, result.value());
}

return out;
}

stx::Result<std::vector<std::wstring>, HRESULT> GetUserProfiles(const Orc::logger& pLog)
{
const auto profiles = ProfileList::GetProfiles(pLog);
Expand Down Expand Up @@ -516,8 +482,6 @@ HRESULT LocationSet::CanonicalizeLocation(

location.assign(szTemp);

location = ExpandOrcStrings(location, _L_);

locType = DeduceLocationType(location.c_str());
if (locType == Location::Undetermined)
return E_INVALIDARG;
Expand Down

0 comments on commit 8beebc9

Please sign in to comment.