Contrary read_file()

new topic     » topic index » view thread      » older message » newer message

Two similar read processes. The first works; the second doesn't.

sequence file_path 
sequence insert_path 
 
file_path = "/home/allen/UCT.dat" 
if file_exists(file_path) then 
   fn = open(file_path,"u",0) 
end if 
UCTree = read_file(fn,BINARY_MODE) 

successfully reads a 6.3 MB file into memory. fn is 3.
But

insert_nmbr = prompt_number("Which subtree?:", {1, number_of_files}) 
insert_path = splice("/home/allen/Extracted/", extracted_files[insert_nmbr][D_NAME], 23) 
if file_exists(insert_path) then 
   insert_fn = open(insert_path, "wb") 
else 
   abort(insert_fn) 
end if 
if insert_fn < 1 then 
   puts(1, "could not open insert file") 
   crash_file("Could open insert file") 
   abort(0) 
end if 
insert_tree = read_file(insert_fn, BINARY_MODE)  

gives no hint of an error. The resulting file path is /home/allen/Extracted/(name of selected file). insert_fn is 4. But insert_tree is an empty sequence, {}. The actual file is a megabyte long.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu