Little changes.

This commit is contained in:
Vreixo Formoso
2007-12-02 17:59:36 +01:00
parent 5fa2490a48
commit 79c37ff193
7 changed files with 207 additions and 51 deletions

View File

@ -25,10 +25,7 @@ struct Iso_Stream
* Opens the stream.
*
* @return
* 1 on success, < 0 on error, 2 file is smaller than expect,
* 3 file is larger than expected (2 and 3 are not errors, they're
* handled by read_block, see there. Moreover, IsooStream
* implementations doesn't need to check that)
* 1 on success, < 0 on error
*/
int (*open)(IsoStream *stream);
@ -39,44 +36,22 @@ struct Iso_Stream
int (*close)(IsoStream *stream);
/**
* Get the size (in bytes) of the stream. This function must return
* always the same size, even if the underlying source file has changed.
* Get the size (in bytes) of the stream.
*/
off_t (*get_size)(IsoStream *stream);
/**
* Read a block (2048 bytes) from the stream.
* Attempts to read up to count bytes from the given stream into
* the buffer starting at buf.
*
* This function should always read the full 2048 bytes, blocking if
* needed. When it reaches EOF, the buf is filled with 0's, if needed.
* Note that the EOF is not reported in that call, but in the next call.
* I.e., when the EOF is reported you can be sure that the function
* has not written anything to the buffer. If the file size is a multiple
* of block size, i.e N*2048, the read_block reports the EOF just when
* reading the N+1 block.
* The stream must be open() before calling this, and close() when no
* more needed.
*
* Note that EOF refers to the original size as reported by get_size.
* If the underlying source size has changed, this function should take
* care of this, truncating the file, or filling the buffer with 0s. I.e.
* this function return 0 (EOF) only when get_size() bytes have been
* readed.
*
* On an I/O error, or a file smaller than the expected size, this
* function returns a [specific error code], and the buffer is filled
* with 0s. Subsequent calls will still return an error code and fill
* buffer with 0's, until EOF (as defined above) is reached, and then
* the function will return 0.
*
* Note that if the current size is larger than expected, you don't get
* any error on reading.
*
* @param buf
* Buffer where data fill be copied, with at least 2048 bytes.
* @return
* 1 sucess, 0 EOF, < 0 error (buf is filled with 0's)
* @return
* number of bytes read, 0 if EOF, < 0 on error
*/
int (*read_block)(IsoStream *stream, void *buf);
int (*read)(IsoStream *stream, void *buf, size_t count);
/**
* Whether this Stram can be read several times, with the same results.
* For example, a regular file is repeatable, you can read it as many
@ -89,6 +64,6 @@ struct Iso_Stream
int refcount;
void *data;
}
};
#endif /*STREAM_H_*/