files copying has failed
Feb 28, 2014 15:21:11 GMT -5
Post by daniel on Feb 28, 2014 15:21:11 GMT -5
If you try to copy a file, e.g. an image file, using the following lines (taken from liberty basic examples)
open "mandelbrot.jpg" for input as #original
open "copy.jpg" for output as #copy
print #copy, input$(#original, lof(#original));
close #original
close #copy
end
the copy.jpg file is corrupted
:o
again , if you try the same with a binary way, like
open "mandelbrot.jpg" for input as #original
a$ = input$(#original, lof(#original))
lenght = lof(#original)
close #original
open "copy.jpg" for random as #copy len = lenght
field #copy, lenght as a$
put #copy,1
close #copy
the file copy.jpg is corrupted again
>:D
I examined with attention the original and the corrupted file discovering a(possible) reason for that.
When the file is written, all the bytes 0D (carriage return,chr$(13)) are substituted by two bytes , namely 0D + 0A
(carriage return + line feed). This seems to happen in whatever fashion you open the file for writing.
How can we overcome the problem ????
open "mandelbrot.jpg" for input as #original
open "copy.jpg" for output as #copy
print #copy, input$(#original, lof(#original));
close #original
close #copy
end
the copy.jpg file is corrupted
:o
again , if you try the same with a binary way, like
open "mandelbrot.jpg" for input as #original
a$ = input$(#original, lof(#original))
lenght = lof(#original)
close #original
open "copy.jpg" for random as #copy len = lenght
field #copy, lenght as a$
put #copy,1
close #copy
the file copy.jpg is corrupted again
>:D
I examined with attention the original and the corrupted file discovering a(possible) reason for that.
When the file is written, all the bytes 0D (carriage return,chr$(13)) are substituted by two bytes , namely 0D + 0A
(carriage return + line feed). This seems to happen in whatever fashion you open the file for writing.
How can we overcome the problem ????