Posted 18 April 2013 - 01:45 AM
ComputerCraft Version Information: 1.52
Description of Bug:
User-Story:
While trying to make use of fs.getSize() I noticed the two peculiarities mentioned above.
The second one of them isn't too much of a problem. Because as long as it remains consistent (always 4 bytes too much) then we can account for that programmatically.
But the first one always showing 512 bytes for smaller files is a bit more problematic.
The way I wanted to use fs.getSize() was to make sure two files had the same size.
My reason for that is that I wanted to process the files byte-by-byte instead of reading them in all at once first.
I don't want to read them in all at once because the files could potentially be quite large.
As it is right now I'll just have to check if a file is <= 512 according to fs.getSize().
If it is, I just read it in all at once, since it isn't that big really.
If it is bigger than 512 bytes, then I can read it byte-by-byte and just keep in mind that it shows 4 bytes too many.
So it's not really a problem for what I'm using it for right now, but I thought I'd mention it in case it wasn't known yet and because
I could imagine there being situations where you'd want to know the exact file size of files < 508 bytes.
If this is intended behaviour though or if I'm missing something, then I'd appreciate someone to point it out to me all the same! :)/>
Edit: Changed "3 bytes too much" into "4 bytes too much" and "509 bytes" into "508 bytes".
Description of Bug:
- If a file is <= 508 bytes, then fs.getSize() will always show its size as 512 bytes.
- If a file is > 508 bytes, then fs.getSize() will always show 4 bytes too much (e.g. 627 bytes will be shown as 630 bytes).
- Create a file <= 508 bytes.
- Call fs.getSize() on the file.
- => Result: "512"
- Create a file > 508 bytes.
- Call fs.getSize() on the file.
- => Result: Real file size + 4 bytes.
User-Story:
While trying to make use of fs.getSize() I noticed the two peculiarities mentioned above.
The second one of them isn't too much of a problem. Because as long as it remains consistent (always 4 bytes too much) then we can account for that programmatically.
But the first one always showing 512 bytes for smaller files is a bit more problematic.
The way I wanted to use fs.getSize() was to make sure two files had the same size.
My reason for that is that I wanted to process the files byte-by-byte instead of reading them in all at once first.
I don't want to read them in all at once because the files could potentially be quite large.
As it is right now I'll just have to check if a file is <= 512 according to fs.getSize().
If it is, I just read it in all at once, since it isn't that big really.
If it is bigger than 512 bytes, then I can read it byte-by-byte and just keep in mind that it shows 4 bytes too many.
So it's not really a problem for what I'm using it for right now, but I thought I'd mention it in case it wasn't known yet and because
I could imagine there being situations where you'd want to know the exact file size of files < 508 bytes.
If this is intended behaviour though or if I'm missing something, then I'd appreciate someone to point it out to me all the same! :)/>
Edit: Changed "3 bytes too much" into "4 bytes too much" and "509 bytes" into "508 bytes".
Edited on 18 April 2013 - 07:40 PM