OSDN Git Service

hfs.c: Detect write failure.
authorJim Meyering <jim@meyering.net>
Mon, 12 Mar 2007 13:58:40 +0000 (14:58 +0100)
committerJim Meyering <jim@meyering.net>
Mon, 12 Mar 2007 13:58:40 +0000 (14:58 +0100)
* libparted/fs/hfs/hfs.c (hfs_extract_file, hfs_extract_bitmap):
(hfs_extract_mdb, hfsplus_extract_file, hfsplus_extract_vh):
Fail when fclose fails for a written-to file handle.

libparted/fs/hfs/hfs.c

index 4824a2e..3323cc0 100644 (file)
@@ -1037,8 +1037,8 @@ hfs_extract_file(const char* filename, HfsPrivateFile* hfs_file)
                        goto err_close;
        }
 
-       fclose(fout);
-       return 1;
+       return (fclose(fout) == 0 ? 1 : 0);
+
 err_close:
        fclose(fout);
        return 0;
@@ -1070,8 +1070,8 @@ hfs_extract_bitmap(const char* filename, PedFileSystem* fs)
                        goto err_close;
        }
 
-       fclose(fout);
-       return 1;
+       return (fclose(fout) == 0 ? 1 : 0);
+
 err_close:
        fclose(fout);
        return 0;
@@ -1090,8 +1090,8 @@ hfs_extract_mdb (const char* filename, PedFileSystem* fs)
        if (!fwrite(extract_buffer, PED_SECTOR_SIZE_DEFAULT, 1, fout))
                goto err_close;
 
-       fclose(fout);
-       return 1;
+       return (fclose(fout) == 0 ? 1 : 0);
+
 err_close:
        fclose(fout);
        return 0;
@@ -1142,8 +1142,8 @@ hfsplus_extract_file(const char* filename, HfsPPrivateFile* hfsp_file)
                        goto err_close;
        }
 
-       fclose(fout);
-       return 1;
+       return (fclose(fout) == 0 ? 1 : 0);
+
 err_close:
        fclose(fout);
        return 0;
@@ -1166,8 +1166,8 @@ hfsplus_extract_vh (const char* filename, PedFileSystem* fs)
        if (!fwrite(extract_buffer, PED_SECTOR_SIZE_DEFAULT, 1, fout))
                goto err_close;
 
-       fclose(fout);
-       return 1;
+       return (fclose(fout) == 0 ? 1 : 0);
+
 err_close:
        fclose(fout);
        return 0;