diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-21 23:49:20 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-21 23:49:20 -0700 |
| commit | 03b43aad42c8eca03937148cda7afffceeeeca1c (patch) | |
| tree | e7eab5a77813521eabe8e12da5fe27456df73670 /toolsrc/src | |
| parent | f03590eeb7f49495b1f3276c56ee3c84843b4bd1 (diff) | |
| download | vcpkg-03b43aad42c8eca03937148cda7afffceeeeca1c.tar.gz vcpkg-03b43aad42c8eca03937148cda7afffceeeeca1c.zip | |
Place command_cache in a separate cpp file
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/commands_cache.cpp | 39 | ||||
| -rw-r--r-- | toolsrc/src/commands_installation.cpp | 32 |
2 files changed, 39 insertions, 32 deletions
diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp new file mode 100644 index 000000000..3a08c4a64 --- /dev/null +++ b/toolsrc/src/commands_cache.cpp @@ -0,0 +1,39 @@ +#include "vcpkg_Commands.h" +#include "vcpkg_System.h" +#include "vcpkg_Files.h" +#include "vcpkg.h" + +namespace vcpkg +{ + void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(0); + + auto begin_it = fs::directory_iterator(paths.packages); + auto end_it = fs::directory_iterator(); + + if (begin_it == end_it) + { + System::println("No packages are cached."); + exit(EXIT_SUCCESS); + } + + for (; begin_it != end_it; ++begin_it) + { + const auto& path = begin_it->path(); + + auto file_contents = Files::get_contents(path / "CONTROL"); + if (auto text = file_contents.get()) + { + auto pghs = parse_paragraphs(*text); + if (pghs.size() != 1) + continue; + + auto src = BinaryParagraph(pghs[0]); + System::println(src.displayname().c_str()); + } + } + + exit(EXIT_SUCCESS); + } +} diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index ba24f74e8..36f26fdab 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -109,38 +109,6 @@ namespace vcpkg exit(EXIT_SUCCESS); } - void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) - { - args.check_max_args(0); - - auto begin_it = fs::directory_iterator(paths.packages); - auto end_it = fs::directory_iterator(); - - if (begin_it == end_it) - { - System::println("No packages are cached."); - exit(EXIT_SUCCESS); - } - - for (; begin_it != end_it; ++begin_it) - { - const auto& path = begin_it->path(); - - auto file_contents = Files::get_contents(path / "CONTROL"); - if (auto text = file_contents.get()) - { - auto pghs = parse_paragraphs(*text); - if (pghs.size() != 1) - continue; - - auto src = BinaryParagraph(pghs[0]); - System::println(src.displayname().c_str()); - } - } - - exit(EXIT_SUCCESS); - } - void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) { std::vector<package_spec> specs = args.parse_all_arguments_as_package_specs(default_target_triplet); |
