Fix little bug, close() must mark a file as closed!
This commit is contained in:
parent
db533b2d99
commit
100919a5cb
@ -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
|
||||
|
@ -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_*/
|
||||
|
@ -67,6 +67,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
file->close(file);
|
||||
}
|
||||
|
||||
|
||||
iso_file_source_unref(file);
|
||||
iso_filesystem_unref(fs);
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ int main(int argc, char **argv)
|
||||
|
||||
while (dir->readdir(dir, &file) == 1) {
|
||||
print_file_src(file);
|
||||
iso_file_source_unref(file);
|
||||
}
|
||||
|
||||
res = dir->close(dir);
|
||||
@ -121,7 +122,8 @@ int main(int argc, char **argv)
|
||||
} else {
|
||||
print_file_src(dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
iso_file_source_unref(dir);
|
||||
iso_filesystem_unref(fs);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user