Fix little bug, close() must mark a file as closed!

This commit is contained in:
Vreixo Formoso
2007-11-26 21:46:26 +01:00
parent db533b2d99
commit 100919a5cb
4 changed files with 23 additions and 10 deletions

View File

@ -151,6 +151,7 @@ int lfs_open(IsoFileSource *src)
static
int lfs_close(IsoFileSource *src)
{
int ret;
_LocalFsFileSource *data;
if (src == NULL) {
@ -160,12 +161,19 @@ int lfs_close(IsoFileSource *src)
data = src->data;
switch(data->openned) {
case 1: /* not dir */
return close(data->info.fd) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
ret = close(data->info.fd) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
break;
case 2: /* directory */
return closedir(data->info.dir) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
ret = closedir(data->info.dir) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
break;
default:
return ISO_FILE_NOT_OPENNED;
ret = ISO_FILE_NOT_OPENNED;
break;
}
if (ret == ISO_SUCCESS) {
data->openned = 0;
}
return ret;
}
static

View File

@ -29,16 +29,17 @@ struct Iso_Stream
/**
* Close the Stream.
* @return 1 on success, < 0 on error
*/
void (*close)(IsoStream *stream);
int (*close)(IsoStream *stream);
// Stream should read in 2k blocks!
//...
int refcount;
void *data;
}
#endif /*STREAM_H_*/