Contrary read_file()
- Posted by alrobnett Jan 16, 2019
- 1013 views
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.