let iter_file_data f fname =
let ic = open_in fname in
- let buf = String.create iter_buf_size in
+ let buf = Bytes.create iter_buf_size in
try
while true do
let bytes = input ic buf 0 iter_buf_size in
if bytes = 0 then raise End_of_file;
- f (String.sub buf 0 bytes)
+ f (Bytes.to_string (Bytes.sub buf 0 bytes))
done
with End_of_file -> close_in ic
let ic = open_in src in
try
let oc = open_out dst in
- let buf = String.create bufsiz in
+ let buf = Bytes.create bufsiz in
(try
while true do
let bytes = input ic buf 0 bufsiz in
(let oc =
open_out (match output with Some f -> f | None -> Filename.basename url)
in
- Http_user_agent.get_iter (fun data -> output_string oc data) url;
+ Http_user_agent.get_iter (fun data -> output_bytes oc data) url;
close_out oc)
| scheme -> (* unsupported scheme *)
failwith ("Http_getter_misc.wget: unsupported scheme: " ^ scheme)
Http_getter_logger.log ~level:3
(sprintf "gzipping %s (keep: %b, output: %s)" fname keep output);
let (ic, oc) = (open_in fname, Gzip.open_out output) in
- let buf = String.create bufsiz in
+ let buf = Bytes.create bufsiz in
(try
while true do
let bytes = input ic buf 0 bufsiz in
try
let ic = Gzip.open_in_chan zic in
let oc = open_out output in
- let buf = String.create bufsiz in
+ let buf = Bytes.create bufsiz in
(try
while true do
let bytes = Gzip.input ic buf 0 bufsiz in
let fname = Pcre.replace ~rex:file_scheme_RE url in
try
let size = (Unix.stat fname).Unix.st_size in
- let buf = String.create size in
+ let buf = Bytes.create size in
let ic = open_in fname in
really_input ic buf 0 size ;
close_in ic;
- Some buf
+ Some (Bytes.to_string buf)
with Unix.Unix_error (Unix.ENOENT, "stat", _) -> None
end else (* other URL, pass it to Http_user_agent *)
try
let temp_file_of_uri uri =
let flat_string s s' c =
- let cs = String.copy s in
+ let cs = Bytes.of_string s in
for i = 0 to (String.length s) - 1 do
if String.contains s' s.[i] then cs.[i] <- c
done;
- cs
+ Bytes.to_string cs
in
let user = try Unix.getlogin () with _ -> "" in
Filename.open_temp_file (user ^ flat_string uri ".-=:;!?/&" '_') ""