I've just looked at FSFile and I've seen that method read() returns void. Why? The number of bytes requested may be not available (yet, because of slow connections, for example). And if user asks to read 0x10001 bytes, filesystem maybe should give 0x10000 bytes, this API does not allow this. Or maybe I don't understand something?

Thanks, S.

sounds like not object oriented

your suggestion sounds good and in fact it is so in some systems (I think in C or Ada). But if something goes wrong while reading from file you will get an exception. That is the way a Java implementation of a filesystem should provide information about errors which occour.
It is better to know WHAT went wrong instead of only knowing THAT something went wrong, isn't it?


Sorry, I was sure that I'll g

Sorry, I was sure that I'll get reply on e-mail and forgotten about this forum Smiling

I'm not speakng about error checking but about speed. Again: hard disk can read number of bytes only multiply of 512. If user requests data by 513 bytes portions, FS should give him back 512 bytes pieces. And same about filesystem block size. Maybe theck must be performed on the other level of API? I haven't found.

another point of view

what you said about the speed of the read method is another point of view.Again I see the advantages of your proposal.

I can not say, wether it is easy to change the API to that behavior.
I think if anyone has the idea to change something, or asks for the reasons for a special behavior of a given part of JNode, it would be great to not just think about the benefits, but write them down.
So everyone who reads it knows what you are talking (thinking) about.


RE: sounds like not object oriented

I think this has nothing to do with object oriented or not. If an _error_ occures while reading from file, then I'd prefer to get an exception, but if I try to read data into a buffer, then I want to know how many bytes are actually read into the buffer.

In java I do things like this:
FileInputStream fileIn = new FileInputStream( "myFile" );
int count = 0;
byte buffer[] = new byte[1024];

while ( (count = fileIn.read( buffer )) > -1 ) {
doSomething( buffer, count );

This way I don't have to check how many bytes are available in the
input before I read.

I agree

in your case it is better to return the number of read bytes.
I thougth the number was the way to check for errors, as alternative to an exception, which I thought would be unusual.