3
3
#include < vcpkg/base/parse.h>
4
4
#include < vcpkg/base/system.debug.h>
5
5
#include < vcpkg/base/system.print.h>
6
+ #include < vcpkg/base/util.h>
6
7
8
+ #include < vcpkg/binarycaching.h>
7
9
#include < vcpkg/commands.xdownload.h>
8
10
#include < vcpkg/vcpkgcmdarguments.h>
9
- #include < vcpkg/vcpkgpaths.h>
10
11
11
12
namespace vcpkg ::Commands::X_Download
12
13
{
@@ -38,11 +39,11 @@ namespace vcpkg::Commands::X_Download
38
39
}
39
40
static bool is_lower_sha512 (StringView sha) { return sha.size () == 128 && is_lower_hex (sha); }
40
41
41
- void perform_and_exit (const VcpkgCmdArguments& args, const VcpkgPaths& paths )
42
+ void perform_and_exit (const VcpkgCmdArguments& args, Files::Filesystem& fs )
42
43
{
43
44
auto parsed = args.parse_arguments (COMMAND_STRUCTURE);
44
- fs::path file = Files::combine (paths. original_cwd , fs::u8path ( args.command_arguments [ 0 ]) );
45
- file. make_preferred ( );
45
+ auto download_manager = create_download_manager ( args.asset_sources_template ). value_or_exit (VCPKG_LINE_INFO );
46
+ fs::path file = fs. absolute (VCPKG_LINE_INFO, fs::u8path (args. command_arguments [ 0 ]) );
46
47
47
48
std::string sha = Strings::ascii_to_lowercase (std::string (args.command_arguments [1 ]));
48
49
if (!is_lower_sha512 (sha))
@@ -51,8 +52,6 @@ namespace vcpkg::Commands::X_Download
51
52
VCPKG_LINE_INFO, " Error: SHA512's must be 128 hex characters: '%s'" , args.command_arguments [1 ]);
52
53
}
53
54
54
- auto & fs = paths.get_filesystem ();
55
-
56
55
// Is this a store command?
57
56
if (Util::Sets::contains (parsed.switches , OPTION_STORE))
58
57
{
@@ -65,7 +64,7 @@ namespace vcpkg::Commands::X_Download
65
64
auto hash =
66
65
Strings::ascii_to_lowercase (Hash::get_file_hash (VCPKG_LINE_INFO, fs, file, Hash::Algorithm::Sha512));
67
66
if (hash != sha) Checks::exit_with_message (VCPKG_LINE_INFO, " Error: file to store does not match hash" );
68
- paths. get_download_manager () .put_file_to_mirror (fs, file, sha).value_or_exit (VCPKG_LINE_INFO);
67
+ download_manager .put_file_to_mirror (fs, file, sha).value_or_exit (VCPKG_LINE_INFO);
69
68
Checks::exit_success (VCPKG_LINE_INFO);
70
69
}
71
70
else
@@ -81,18 +80,18 @@ namespace vcpkg::Commands::X_Download
81
80
auto it_urls = parsed.multisettings .find (OPTION_URL);
82
81
if (it_urls == parsed.multisettings .end ())
83
82
{
84
- paths. get_download_manager () .download_file (fs, View<std::string>{}, headers, file, sha);
83
+ download_manager .download_file (fs, View<std::string>{}, headers, file, sha);
85
84
}
86
85
else
87
86
{
88
- paths. get_download_manager () .download_file (fs, it_urls->second , headers, file, sha);
87
+ download_manager .download_file (fs, it_urls->second , headers, file, sha);
89
88
}
90
89
Checks::exit_success (VCPKG_LINE_INFO);
91
90
}
92
91
}
93
92
94
- void XDownloadCommand::perform_and_exit (const VcpkgCmdArguments& args, const VcpkgPaths& paths ) const
93
+ void XDownloadCommand::perform_and_exit (const VcpkgCmdArguments& args, Files::Filesystem& fs ) const
95
94
{
96
- X_Download::perform_and_exit (args, paths );
95
+ X_Download::perform_and_exit (args, fs );
97
96
}
98
97
}
0 commit comments