The following test program shows how I am able to reproduce the error on my system. It happens everytime the program is run.
------------
testd.d
------------
import std.file;
import std.stdio;
void main()
{
char[] contents = cast(char[]) std.file.read("test_file.txt");
writefln( contents );
}
--------------
test_file.txt
--------------
name = dunzip
[dunzip.d]
target = dunzip
If you type the contents of test_file.txt, it will work. It only fails when the line ending is not that of OS X.
My procedure to reproduce was the following: (it would have been easier to upload the text file but i can't upload stuff here...)
* go to http://www.dsource.org/projects/dsss/wiki/DSSSByExample, copy the contents of the file depicted above
* paste them in either smultron or textedit. save the file to "test_file.txt" next to the executable.
* run the executable. it prints only "target = HelloWorld".
* In smultron, if i then select "Text > Line Ending > Unix" and save, running the program now gives correct line endings.
The read method should load the data with whatever line endings the file contains, however it should not truncate data, especially not when the same file opens correctly in all OS X text editors.
The following code was tested on OS X 10.4.10, PPC, G4 (32-bits). It ran correctly when the same procedure was done in Linux.
Comment #1 by fire_void — 2007-08-26T19:06:28Z
Created attachment 171
An example of file that causes problem
(Ah you can post atatchements after the initial post)
Attached is a file that shows the problem
Comment #2 by dvdfrdmn — 2007-08-28T19:14:58Z
Phobos is not truncating the data. What you are seeing is overtyping done by the terminal software. If you run the 'cat' program on the file, it will produce the same result. std.file.read just returns an array of bytes and should not perform any kind of translation.