Skip to content

Commit

Permalink
Allow use of UNC paths on Windows
Browse files Browse the repository at this point in the history
This fixes issue #619.
  • Loading branch information
kyllingstad committed Feb 26, 2024
1 parent 02e1d8c commit ba97425
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/cosim/orchestration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ std::shared_ptr<model> fmu_file_uri_sub_resolver::lookup_model(const uri& modelU
{
assert(modelUri.scheme().has_value());
if (*modelUri.scheme() != "file") return nullptr;
#ifndef _WIN32
if (modelUri.authority().has_value() &&
!(modelUri.authority()->empty() || *modelUri.authority() == "localhost")) {
return nullptr;
}
#endif
if (modelUri.query().has_value() || modelUri.fragment().has_value()) {
BOOST_LOG_SEV(log::logger(), log::warning)
<< "Query and/or fragment component(s) in a file:// URI were ignored: "
Expand Down
5 changes: 2 additions & 3 deletions src/cosim/uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,6 @@ uri path_to_file_uri(const cosim::filesystem::path& path)
cosim::filesystem::path file_uri_to_path(const uri& fileUri)
{
COSIM_INPUT_CHECK(fileUri.scheme() && *fileUri.scheme() == "file");
COSIM_INPUT_CHECK(fileUri.authority() &&
(fileUri.authority()->empty() || *fileUri.authority() == "localhost"));

#ifdef _WIN32
// Windows has some special rules for file URIs; better use the built-in
// functions.
Expand All @@ -554,6 +551,8 @@ cosim::filesystem::path file_uri_to_path(const uri& fileUri)
return cosim::filesystem::path(pathBuffer, pathBuffer + pathSize);

#else
COSIM_INPUT_CHECK(fileUri.authority() &&
(fileUri.authority()->empty() || *fileUri.authority() == "localhost"));
return cosim::filesystem::path(percent_decode(fileUri.path()));
#endif
}
Expand Down

0 comments on commit ba97425

Please sign in to comment.