Skip to content

Commit

Permalink
according to gnudatalanguage#1645 that's what must be done to work on…
Browse files Browse the repository at this point in the history
… windows too
  • Loading branch information
GillesDuvert committed Jan 18, 2023
1 parent ccbf88c commit 7a0e9cc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pro/utilities/idlneturl__define.pro
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function idlneturl::Get, buffer=buffer, filename=filename, string_array=string_a
if self.ftp_connection_mode EQ 0 then curl_cmd+='--ftp-pasv '
; headers
if ptr_valid(self.headers) and n_elements(*(self.headers)) gt 0 then begin
for i=0,n_elements(*(self.headers))-1 do begin
if strlen((*self.headers)[i]) gt 0 then curl_cmd+="-H '"+strtrim((*self.headers)[i],2)+"' "
for i=0,n_elements(*(self.headers))-1 do begin ; note below curl under Windows accept only "-quote see #1465
if strlen((*self.headers)[i]) gt 0 then curl_cmd+='-H "'+strtrim((*self.headers)[i],2)+'" ' ; was: if strlen((*self.headers)[i]) gt 0 then curl_cmd+="-H '"+strtrim((*self.headers)[i],2)+"' "
endfor
endif

Expand Down Expand Up @@ -128,7 +128,7 @@ function idlneturl::Get, buffer=buffer, filename=filename, string_array=string_a
; been downloaded. When we write this function directly in GDL using
; libcurl, things will be way esaier.
curl_asyn_get_headers='curl -LI --silent --show-error --include ' ; will get only headers
curl_asyn_get_headers+="--write-out '\n%{size_header}\n%{content_type}\n%{response_code}\n%{size_download}' " ; we get some useful values
curl_asyn_get_headers+='--write-out "\n%{size_header}\n%{content_type}\n%{response_code}\n%{size_download}" ' ; we get some useful values
cmd=curl_asyn_get_headers+id_cmd
if KEYWORD_SET(verbose) then print, cmd
SPAWN, cmd, result, blahblah
Expand Down Expand Up @@ -175,7 +175,7 @@ function idlneturl::Get, buffer=buffer, filename=filename, string_array=string_a
; number of bytes downloaded at each instant, aka progress_info[2]
; of course if the transfer encoding is not 'chunked'.

curl_asyn_get_all='curl -L --progress-bar -o '+filename+' ' ; will use progressbar values, but alas need output in external file.
curl_asyn_get_all='curl -L --progress-bar -o "'+filename+'" ' ; will use progressbar values, but alas need output in external file.
; remove /tmp/pb
file_delete,'/tmp/pb',/allow_nonexistent,/quiet,/noexpand_path

Expand Down Expand Up @@ -206,7 +206,7 @@ no_callback:
; if there is no callback function, directly get the file as we do not
; need to be asynchronous. Best is to create the 'filename' directly.

curl_syn='curl -L --silent --show-error -o '+filename+' '
curl_syn='curl -L --silent --show-error -o "'+filename+'" '
cmd=curl_syn+curl_cmd+id_cmd
if KEYWORD_SET(verbose) then print, cmd
SPAWN, cmd, result, blahblah
Expand Down
52 changes: 52 additions & 0 deletions src/pro/utilities/n_bytes.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function N_bytes,a
;+
; NAME:
; N_bytes()
;
; PURPOSE:
; To return the total number of bytes in data element
;
; CALLING SEQUENCE:
; result = N_bytes(a)
;
; INPUTS:
; a - any idl data element, scalar or array
;
; OUTPUTS:
; total number of bytes in a is returned as the function value
; (64bit longword scalar)
; NOTES:
; (1) Not valid for object or pointer data types
; (2) For a string array, the number of bytes is computed after conversion
; with the BYTE() function, i.e. each element has the same length,
; equal to the maximum individual string length.
;
; MODIFICATION HISTORY:
; Version 1 By D. Lindler Oct. 1986
; Include new IDL data types W. Landsman June 2001
; Now return a 64bit integer W. Landsman April 2006
;-
;-----------------------------------------------------
;
dtype = size(a,/type) ;data type
if dtype EQ 0 then return,0 ;undefined
nel = N_elements(a)
case dtype of
1: nb = 1 ;Byte
2: nb = 2 ;16 bit signed integer
3: nb = 4 ;32 bit signed integer
4: nb = 4 ;Float
5: nb = 8 ;Double
6: nb = 8 ;Complex
7: nb = max(strlen(a)) ;String
8: nb = N_tags(a,/length) ;Structure
9: nb = 16 ;Double Complex
12: nb = 2 ;Unsigned 16 bit Integer
13: nb = 4 ;Unsigned 32 bit Integer
14: nb = 8 ;64 bit signed integer
15: nb = 8 ;64 bit unsigned integer
else: message,'ERROR - Object or Pointer data types not valid'
endcase

return,long64(nel)*nb
end

0 comments on commit 7a0e9cc

Please sign in to comment.