From af120041b68f2b9221bdd3cf0047f7e20705aa5a Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 29 Nov 2016 17:04:41 -0800 Subject: Move file functions to vcpkg_Files.h --- toolsrc/include/vcpkg_Files.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 445713965..4aa9b956a 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -2,9 +2,12 @@ #include "expected.h" #include +#include namespace vcpkg {namespace Files { + namespace fs = std::tr2::sys; + static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; void check_is_directory(const std::tr2::sys::path& dirpath); @@ -14,4 +17,28 @@ namespace vcpkg {namespace Files expected get_contents(const std::tr2::sys::path& file_path) noexcept; std::tr2::sys::path find_file_recursively_up(const std::tr2::sys::path& starting_dir, const std::string& filename); + + template + void non_recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector* output) + { + std::copy_if(fs::directory_iterator(dir), fs::directory_iterator(), std::back_inserter(*output), predicate); + } + + template + void recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector* output) + { + std::copy_if(fs::recursive_directory_iterator(dir), fs::recursive_directory_iterator(), std::back_inserter(*output), predicate); + } + + template + std::vector recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate) + { + std::vector v; + recursive_find_matching_paths_in_dir(dir, predicate, &v); + return v; + } + + void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector* output); + + std::vector recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension); }} -- cgit v1.2.3 From 74f69ade187dbe091cb00ace4d40ef9d20a3e416 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 29 Nov 2016 17:17:45 -0800 Subject: Introduce PostBuildLint namespace --- toolsrc/include/BuildInfo.h | 4 ++-- toolsrc/include/post_build_lint.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/BuildInfo.h b/toolsrc/include/BuildInfo.h index ccf40abbf..7c654d9c7 100644 --- a/toolsrc/include/BuildInfo.h +++ b/toolsrc/include/BuildInfo.h @@ -6,7 +6,7 @@ namespace fs = std::tr2::sys; -namespace vcpkg +namespace vcpkg { namespace PostBuildLint { enum class LinkageType { @@ -128,4 +128,4 @@ namespace vcpkg }; BuildInfo read_build_info(const fs::path& filepath); -} +}} diff --git a/toolsrc/include/post_build_lint.h b/toolsrc/include/post_build_lint.h index bc916a7af..a5fb9149f 100644 --- a/toolsrc/include/post_build_lint.h +++ b/toolsrc/include/post_build_lint.h @@ -2,7 +2,7 @@ #include "package_spec.h" #include "vcpkg_paths.h" -namespace vcpkg +namespace vcpkg {namespace PostBuildLint { void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths); -} +}} -- cgit v1.2.3 From 0b996a002ec6d90d8a132e7603553b60b332c9fe Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 29 Nov 2016 18:08:00 -0800 Subject: [Files] Add functions to get all files of a dir recursively or non-recursively --- toolsrc/include/vcpkg_Files.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 4aa9b956a..8ed1eabe1 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -41,4 +41,12 @@ namespace vcpkg {namespace Files void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector* output); std::vector recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension); + + void recursive_find_all_files_in_dir(const fs::path& dir, std::vector* output); + + std::vector recursive_find_all_files_in_dir(const fs::path& dir); + + void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector* output); + + std::vector non_recursive_find_all_files_in_dir(const fs::path& dir); }} -- cgit v1.2.3 From 0042316c4b57cf91ded8e474a8dda354340e7381 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 29 Nov 2016 18:08:53 -0800 Subject: Introduce filesystem_fs.h --- toolsrc/include/BuildInfo.h | 2 -- toolsrc/include/Paragraphs.h | 3 +-- toolsrc/include/coff_file_reader.h | 4 +--- toolsrc/include/filesystem_fs.h | 5 +++++ toolsrc/include/vcpkg.h | 3 --- toolsrc/include/vcpkg_Files.h | 10 ++++------ toolsrc/include/vcpkg_System.h | 5 ++--- toolsrc/include/vcpkg_paths.h | 4 +--- 8 files changed, 14 insertions(+), 22 deletions(-) create mode 100644 toolsrc/include/filesystem_fs.h (limited to 'toolsrc/include') diff --git a/toolsrc/include/BuildInfo.h b/toolsrc/include/BuildInfo.h index 7c654d9c7..9f872385e 100644 --- a/toolsrc/include/BuildInfo.h +++ b/toolsrc/include/BuildInfo.h @@ -4,8 +4,6 @@ #include "Paragraphs.h" #include -namespace fs = std::tr2::sys; - namespace vcpkg { namespace PostBuildLint { enum class LinkageType diff --git a/toolsrc/include/Paragraphs.h b/toolsrc/include/Paragraphs.h index 22aaefe98..9e9fafe49 100644 --- a/toolsrc/include/Paragraphs.h +++ b/toolsrc/include/Paragraphs.h @@ -1,11 +1,10 @@ #pragma once -#include +#include "filesystem_fs.h" #include namespace vcpkg { namespace Paragraphs { - namespace fs = std::tr2::sys; std::vector> get_paragraphs(const fs::path& control_path); std::vector> parse_paragraphs(const std::string& str); }} diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h index 81f107f10..1a9a071ef 100644 --- a/toolsrc/include/coff_file_reader.h +++ b/toolsrc/include/coff_file_reader.h @@ -1,12 +1,10 @@ #pragma once #include #include "MachineType.h" -#include +#include "filesystem_fs.h" namespace vcpkg {namespace COFFFileReader { - namespace fs = std::tr2::sys; - struct dll_info { MachineType machine_type; diff --git a/toolsrc/include/filesystem_fs.h b/toolsrc/include/filesystem_fs.h new file mode 100644 index 000000000..ece485c23 --- /dev/null +++ b/toolsrc/include/filesystem_fs.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +namespace fs = std::tr2::sys; \ No newline at end of file diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index 81b4d45ba..832fb1920 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -1,6 +1,5 @@ #pragma once -#include #include "package_spec.h" #include "BinaryParagraph.h" #include "StatusParagraphs.h" @@ -8,8 +7,6 @@ namespace vcpkg { - namespace fs = std::tr2::sys; - extern bool g_do_dry_run; StatusParagraphs database_load_check(const vcpkg_paths& paths); diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 8ed1eabe1..aa25d8333 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -1,22 +1,20 @@ #pragma once #include "expected.h" -#include +#include "filesystem_fs.h" #include namespace vcpkg {namespace Files { - namespace fs = std::tr2::sys; - static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; - void check_is_directory(const std::tr2::sys::path& dirpath); + void check_is_directory(const fs::path& dirpath); bool has_invalid_chars_for_filesystem(const std::string s); - expected get_contents(const std::tr2::sys::path& file_path) noexcept; + expected get_contents(const fs::path& file_path) noexcept; - std::tr2::sys::path find_file_recursively_up(const std::tr2::sys::path& starting_dir, const std::string& filename); + fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename); template void non_recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector* output) diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h index c420464c1..e059bde0a 100644 --- a/toolsrc/include/vcpkg_System.h +++ b/toolsrc/include/vcpkg_System.h @@ -1,12 +1,11 @@ #pragma once #include "vcpkg_Strings.h" - -#include +#include "filesystem_fs.h" namespace vcpkg {namespace System { - std::tr2::sys::path get_exe_path_of_current_process(); + fs::path get_exe_path_of_current_process(); struct exit_code_and_output { diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h index 2dc9c7636..a2932070d 100644 --- a/toolsrc/include/vcpkg_paths.h +++ b/toolsrc/include/vcpkg_paths.h @@ -1,13 +1,11 @@ #pragma once -#include +#include "filesystem_fs.h" #include "expected.h" #include "package_spec.h" #include "BinaryParagraph.h" namespace vcpkg { - namespace fs = std::tr2::sys; - struct vcpkg_paths { static expected create(const fs::path& vcpkg_root_dir); -- cgit v1.2.3 From ae379fedea589552ad7c98eb350c492ce830fb48 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 30 Nov 2016 14:08:43 -0800 Subject: Move print_paths() to Files:: --- toolsrc/include/vcpkg_Files.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index aa25d8333..8b320303d 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -47,4 +47,6 @@ namespace vcpkg {namespace Files void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector* output); std::vector non_recursive_find_all_files_in_dir(const fs::path& dir); + + void print_paths(const std::vector& paths); }} -- cgit v1.2.3 From 89aaf195fbdfa63708fd6ac90103cac0cdedf3c6 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 01:37:41 -0800 Subject: Remove unused variable --- toolsrc/include/vcpkg.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index 832fb1920..2fc993616 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -7,19 +7,17 @@ namespace vcpkg { - extern bool g_do_dry_run; - StatusParagraphs database_load_check(const vcpkg_paths& paths); void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db); void deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db); expected try_load_port(const fs::path& control_path); + inline expected try_load_port(const vcpkg_paths& paths, const std::string& name) { return try_load_port(paths.ports / name); } expected try_load_cached_package(const vcpkg_paths& paths, const package_spec& spec); - } // namespace vcpkg -- cgit v1.2.3 From 6eac44c9640a50fbde88535df6261a1a3f234350 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 01:49:24 -0800 Subject: Move install_package() and deinstall_package() to the files of the appropriate commands --- toolsrc/include/vcpkg.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index 2fc993616..ef78e213e 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -9,8 +9,7 @@ namespace vcpkg { StatusParagraphs database_load_check(const vcpkg_paths& paths); - void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db); - void deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db); + void write_update(const vcpkg_paths& paths, const StatusParagraph& p); expected try_load_port(const fs::path& control_path); -- cgit v1.2.3