diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-21 21:43:59 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-21 21:43:59 -0700 |
| commit | 54341f745c134d740ddc6a6538483070ad5877ef (patch) | |
| tree | 44496d7e98adccd73a980b87f1049a1894ab801d /toolsrc/src | |
| parent | a1b7756c456137b0a9c169a4be03170da81cd5d7 (diff) | |
| download | vcpkg-54341f745c134d740ddc6a6538483070ad5877ef.tar.gz vcpkg-54341f745c134d740ddc6a6538483070ad5877ef.zip | |
MOve recursive upwards search to Files
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/main.cpp | 17 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Files.cpp | 15 |
2 files changed, 16 insertions, 16 deletions
diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index d3fb855d1..e9ce4702c 100644 --- a/toolsrc/src/main.cpp +++ b/toolsrc/src/main.cpp @@ -23,21 +23,6 @@ void invalid_command(const std::string& cmd) exit(EXIT_FAILURE); } -static fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename) -{ - fs::path current_dir = starting_dir; - for (; !current_dir.empty(); current_dir = current_dir.parent_path()) - { - const fs::path candidate = current_dir / filename; - if (fs::exists(candidate)) - { - break; - } - } - - return current_dir; -} - static void inner(const vcpkg_cmd_arguments& args) { TrackProperty("command", args.command); @@ -67,7 +52,7 @@ static void inner(const vcpkg_cmd_arguments& args) } else { - vcpkg_root_dir = find_file_recursively_up(fs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root"); + vcpkg_root_dir = Files::find_file_recursively_up(fs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root"); } } diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 49a661157..ef330ea27 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -35,4 +35,19 @@ namespace vcpkg {namespace Files return std::move(output); } + + fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename) + { + fs::path current_dir = starting_dir; + for (; !current_dir.empty(); current_dir = current_dir.parent_path()) + { + const fs::path candidate = current_dir / filename; + if (fs::exists(candidate)) + { + break; + } + } + + return current_dir; + } }} |
