#include <stdarg.h>
#include "dentry.h"
+#include <unistd.h>
+#include <fcntl.h>
#ifdef WITH_NTFS_3G
#include <time.h>
if (lte->resource_entry.flags & WIM_RESHDR_FLAG_METADATA) {
if (w->current_image == w->hdr.image_count) {
- ERROR("Expected only %u images, but found more",
+ ERROR("The WIM header says there are %u images in the WIM,\n"
+ " but we found more metadata resources than this",
w->hdr.image_count);
ret = WIMLIB_ERR_IMAGE_COUNT;
} else {
return WIMLIB_ERR_INVALID_IMAGE;
}
-
/* If a valid image is currently selected, it can be freed if it is not
* modified. */
if (w->current_image != WIM_NO_IMAGE) {
}
/* Opens a WIM writable */
-int open_wim_writable(WIMStruct *w, const char *path)
+int open_wim_writable(WIMStruct *w, const char *path,
+ bool trunc, bool readable)
{
+ const char *mode;
+ if (trunc)
+ if (readable)
+ mode = "w+b";
+ else
+ mode = "wb";
+ else
+ mode = "r+b";
+
+ DEBUG("Opening `%s' read-write", path);
wimlib_assert(w->out_fp == NULL);
wimlib_assert(path != NULL);
- w->out_fp = fopen(path, "w+b");
+ w->out_fp = fopen(path, mode);
if (!w->out_fp) {
- ERROR_WITH_ERRNO("Failed to open `%s' for writing",
- path);
+ ERROR_WITH_ERRNO("Failed to open `%s' for writing", path);
return WIMLIB_ERR_OPEN;
}
return 0;
if (open_flags & WIMLIB_OPEN_FLAG_CHECK_INTEGRITY) {
ret = check_wim_integrity(w,
- open_flags & WIMLIB_OPEN_FLAG_SHOW_PROGRESS);
+ (open_flags & WIMLIB_OPEN_FLAG_SHOW_PROGRESS) != 0);
if (ret == WIM_INTEGRITY_NONEXISTENT) {
WARNING("No integrity information for `%s'; skipping "
"integrity check.", w->filename);