#DiskReads & Size?
3 messages in this thread
Another AmigaDos question. I am porting over the part of the program that
reads in a disk file into a 16K buffer. I understand that I can set my block
size to 16K and just keep reading. Question is how do I get the files total
size? I guess I could keep doing reads until I get back less then my requested
block size but it would be nice to be able to say (early on) Sorry this file is
too large to load in. Thanks.
There are quite a few ways of finding the size of a file. Traditional method:
get a lock on the file, set aside an InfoData area, and then call
Info(lock,info_Data). You can read file size in bytes OR in blocks from the
FileInfoBlock. Don't forget to release the lock when you're done. Anothe way,
when the file has been opened, is to use the Seek(handle, position, mode) call.
Since mode permits OFFSET_BEGINNING, OFFSET_CURRENT, and OFFSET_END, and the
Seek function returns "oldPosition", it's not hard to work out the sequence to
get a file length.
–Jim
Ok Jim, Thanks much for your reply. I will make my conversion a lot "cleaner"
Best to you and yours.