I have a static site generator I wrote in Arc, and one thing that I needed for that is to copy non-generated files to the output -- e.g. css, some javascript files, etc. I now know that in Anarki's libraries is a method `cp`, that copies files. That should work (subject to getting an answer for http://www.arclanguage.org/item?id=20200). But before I knew about that, I wrote my own: (def copy-file (src-loc dest-loc)
(w/infile src src-loc
(w/outfile dest dest-loc
(whilet char (readc src)
(disp char dest)))))
This seems to work just fine for text. But for my favicon file, I get corrupted results. Most of the file seems to be copied fine. The first part that is different starts like this:00000060: 7f00 8989 8900 8f8f 8f00 9898 9800 a4a4 ................
00000070: a400 acac ac00 aeae ae00 b2b2 b200 b5b5 ................ and ends up being copied like this: 00000060: 7f00 efbf bdef bfbd efbf bd00 efbf bdef ................
00000070: bfbd efbf bd00 efbf bdef bfbd efbf bd00 ................ The file also starts as 1406 bytes, and ends up as 1526 bytes. Any idea why this would be? The code seems pretty simple, so I'm not sure where the bug exists. |