/[mldonkey]/mldonkey/src/utils/cdk/file.ml
ViewVC logotype

Diff of /mldonkey/src/utils/cdk/file.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by simon_mld, Thu Apr 24 12:45:46 2003 UTC revision 1.3 by spiralvoice, Thu Jul 14 14:02:28 2005 UTC
# Line 25  let to_string name = Line 25  let to_string name =
25    let cont = ref true in    let cont = ref true in
26    let rec iter buf nb_read =    let rec iter buf nb_read =
27      let buf_size = String.length buf in      let buf_size = String.length buf in
28      let to_read = min (buf_size - nb_read) 10000 in      let to_read = min (buf_size - nb_read) 8192 in
29      let tmp = input chan buf nb_read to_read in      let tmp = input chan buf nb_read to_read in
30      if tmp = 0 then      if tmp = 0 then
31        String.sub buf 0 nb_read        String.sub buf 0 nb_read
# Line 41  let to_string name = Line 41  let to_string name =
41    let buf = iter buf 0 in    let buf = iter buf 0 in
42    close_in chan;    close_in chan;
43    buf    buf
44      
45    let read_whole_chan chan =
46      let buf = Buffer.create 1024 in
47      let rec loop () =
48        Buffer.add_char buf (input_char chan);
49        loop ()
50      in
51      try
52        loop ()
53      with
54        End_of_file -> close_in chan; buf
55    
56    let to_string_alt name =
57      let chan = open_in_bin name in
58      read_whole_chan chan
59    
60    let to_copy in_name out_name =
61      let in_chan = open_in_bin in_name and
62      out_chan = open_out_bin out_name in
63      try
64        let rec rcpy () =
65          let c = input_byte in_chan in
66          output_byte out_chan c;
67          flush out_chan;
68          rcpy ();
69        in
70        rcpy ()
71      with
72        End_of_file -> ()
73    
74  let from_string name s =  let from_string name s =
75    let oc = open_out name in    let oc = open_out name in
76    output_string oc s;    output_string oc s;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26