diff --git a/src/fs_local.c b/src/fs_local.c index b4bdfce..576d295 100644 --- a/src/fs_local.c +++ b/src/fs_local.c @@ -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 diff --git a/src/stream.h b/src/stream.h index 6c20479..e5941ee 100644 --- a/src/stream.h +++ b/src/stream.h @@ -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_*/ diff --git a/test/cat.c b/test/cat.c index a0c52ae..4a42191 100644 --- a/test/cat.c +++ b/test/cat.c @@ -67,6 +67,8 @@ int main(int argc, char **argv) } file->close(file); } - + + iso_file_source_unref(file); + iso_filesystem_unref(fs); return 0; } diff --git a/test/lsl.c b/test/lsl.c index 4c45ec7..ee59c5a 100644 --- a/test/lsl.c +++ b/test/lsl.c @@ -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; }