Posts: 858
Threads: 196
Joined: Apr 2005
I'm trying:
Macro
Macro22
str f="http://download.kiwix.org/portable/wikipedia_es_all.zip"
out IntGetFileSize(f)
Error (RT) in Macro22: unknown size.
Is there another way?
Posts: 11,871
Threads: 138
Joined: Dec 2002
Because file size was more than int range. This version supports any file size. Returns long, not int.
Function
IntGetFileSize
;/
function'long $url [inetflags]
;Returns internet file size.
;url - file URL.
;inetflags - optional dwFlags argument for InternetOpenUrl API.
;REMARKS
;Sends request to download the file, but gets only response headers, not whole file.
;Error if fails, or if file size is not specified in response headers (no Content-Length header).
#opt nowarnings 1
Http http
__HInternet hi=InternetOpenUrl(http.hinternet(1) url 0 0 inetflags 0); if(!hi) end "failed"
_s.all(30); _i=30
if(!HttpQueryInfo(hi HTTP_QUERY_CONTENT_LENGTH _s &_i 0)) end "unknown size"
ret val(_s.fix 1)
Posts: 858
Threads: 196
Joined: Apr 2005
Thanks.
Is possible to get 'Last modified' of file?
Posts: 11,871
Threads: 138
Joined: Dec 2002
Function
IntGetLastModified
;/
function'DateTime $url [inetflags] ;;flags: convert UTC/GMT to local time
;Returns internet file Last-Modified date.
;url - file URL.
;inetflags - optional dwFlags argument for InternetOpenUrl API.
;REMARKS
;Sends request to download the file, but gets only response headers, not whole file.
;Error if fails, or if there is no Last-Modified header.
;The date is in GMT time zone, which is the same as UTC. Use UtcToLocal if need your local time, see example.
;EXAMPLE
;DateTime t=IntGetLastModified("http://www.quickmacros.com/support.html")
;t.UtcToLocal
;out t.ToStr
#opt nowarnings 1
Http http
__HInternet hi=InternetOpenUrl(http.hinternet(1) url 0 0 inetflags 0); if(!hi) end "failed"
SYSTEMTIME st; _i=sizeof(st)
if(!HttpQueryInfo(hi HTTP_QUERY_LAST_MODIFIED|HTTP_QUERY_FLAG_SYSTEMTIME &st &_i 0)) end "unknown Last-Modified"
DateTime r.FromSYSTEMTIME(st)
ret r
Function
IntGetLastModifiedString
;/
function'str $url [inetflags]
;Returns internet file Last-Modified date as raw header string.
;url - file URL.
;inetflags - optional dwFlags argument for InternetOpenUrl API.
;REMARKS
;Sends request to download the file, but gets only response headers, not whole file.
;Error if fails, or if there is no Last-Modified header.
#opt nowarnings 1
Http http
__HInternet hi=InternetOpenUrl(http.hinternet(1) url 0 0 inetflags 0); if(!hi) end "failed"
_s.all(300); _i=300
if(!HttpQueryInfo(hi HTTP_QUERY_LAST_MODIFIED _s &_i 0)) end "unknown Last-Modified"
ret _s.fix
Posts: 858
Threads: 196
Joined: Apr 2005