Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit c09a273

Browse files
Eric ForgyEric Forgy
authored andcommitted
Use BinDeps.download_cmd for Windows.
1 parent 38d7786 commit c09a273

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/WinRPM.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,13 @@ end
4444

4545
@unix_only download(source::AbstractString) = (x=HTTPC.get(source); (bytestring(x.body),x.http_code))
4646
@windows_only function download(source::AbstractString; retry = 5)
47-
dest = Array(UInt16,261)
47+
filename = joinpath(dirname(@__FILE__),"..","cache",basename(source))
4848
for i in 1:retry
49-
res = ccall((:URLDownloadToCacheFileW,:urlmon),stdcall,Cuint,
50-
(Ptr{Void},Ptr{UInt16},Ptr{UInt16},Clong,Cint,Ptr{Void}),
51-
C_NULL,utf16(source),dest,sizeof(dest)>>1,0,C_NULL)
52-
if res == 0
53-
resize!(dest, findfirst(dest, 0))
54-
filename = LegacyStrings.utf8(UTF16String(dest))
55-
if isfile(filename)
56-
return readall(filename),200
57-
end
58-
else
59-
warn("Unknown download failure, error code: $res")
49+
run(BinDeps.download_cmd(source,filename))
50+
if isfile(filename)
51+
str = readall(filename)
52+
rm(filename)
53+
return str, 200
6054
end
6155
warn("Retry $i/$retry downloading: $source")
6256
end
@@ -503,4 +497,3 @@ end
503497
include("winrpm_bindeps.jl")
504498

505499
end
506-

0 commit comments

Comments
 (0)