forum-msg-id-133452-edit

Original date:2019-01-16 13:26:42 Edited by: ChrisB Subject: Re: Contrary read_file()

Sometimes writing English pseudocode helps

alrobnett said...
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                        --if the file exists then 
   insert_fn = open(insert_path, "wb")                  --open it for writing in binary (ie delete it and write a new one) 
else                                                    --otherwise if the file doesn't exist 
   abort(insert_fn)                                     --abort the program, and display the file handle 
                                                        --ah, if I didn't open the file for writing,  
                                                        --then where has that handle come from 
end if 
if insert_fn < 1 then                                   --if the file doesn't exist then 
                                                        --(but note I would never have got here if the file didn't exist) 
   puts(1, "could not open insert file")                --print your error reporting and stuff 
   crash_file("Could open insert file")                 --looks like this block would never be run 
   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.

Cheers

Chris

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu