bmeck
Joined: 22 May 2007 Posts: 6
|
Posted: Thu May 24, 2007 3:11 am Post subject: copyFrom not working |
|
|
Hello there, I have a simple stream to stream action going on dumping a files contents into a stream "str" and looking at the API I tried using the copyFrom method to grab all of that data in the file but it does not always fully copy the file ( and when you throw in a try catch block, nothing comes up either ). Any ideas?
Code: |
// Get File to stream
BufferedFile handle = new BufferedFile ( file, FileMode.In );
// Throw all of the contents into str
str.copyFrom( handle );
// Close the file
handle.close();
|
Now this does seem to consistantly get all of the data instead of using copyFrom, but I cannot find a way to get it to only send the amount of bytes I want it to instead of the whole buffer. Maybe I just don't know how to use copyExact?
Code: |
ubyte[] buffer = new ubyte[1024];
uint size;
uint hold;
while ( ! handle.eof ( ) )
{
size = handle.read ( buffer );
if ( size == 0 ) break;
hold = str.write ( buffer );
writefln ( "\n\nin:%d::out:%d\n\n", size, hold );
}
|
|
|