FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

copyFrom not working

 
Post new topic   Reply to topic     Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
bmeck



Joined: 22 May 2007
Posts: 6

PostPosted: Thu May 24, 2007 3:11 am    Post subject: copyFrom not working Reply with quote

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 );
}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group