file = OPEN_WRITE(saving_filename);
if(file == NULL)
{
- std::cout << "Cannot open image file: " << filename << std::endl;
+ std::cout << "Cannot open image file: " << saving_filename << std::endl;
std::cout << strerror(errno) << std::endl;
return false;
}
if(safe_fwrite(code->allocator->first_block(),h.code_size,1,file) != 1) ok = false;
if(safe_fclose(file)) ok = false;
- MOVE_FILE(saving_filename,filename);
if(!ok)
std::cout << "save-image failed: " << strerror(errno) << std::endl;
+ else
+ MOVE_FILE(saving_filename,filename);
return ok;
}
/* do a full GC to push everything into tenured space */
primitive_compact_gc();
- data_root<byte_array> path1(ctx->pop(),this);
- path1.untag_check(this);
data_root<byte_array> path2(ctx->pop(),this);
path2.untag_check(this);
+ data_root<byte_array> path1(ctx->pop(),this);
+ path1.untag_check(this);
save_image((vm_char *)(path1.untagged() + 1 ),(vm_char *)(path2.untagged() + 1));
}
/* We unbox this before doing anything else. This is the only point
where we might throw an error, so we have to throw an error here since
later steps destroy the current image. */
- data_root<byte_array> path1(ctx->pop(),this);
- path1.untag_check(this);
data_root<byte_array> path2(ctx->pop(),this);
path2.untag_check(this);
+ data_root<byte_array> path1(ctx->pop(),this);
+ path1.untag_check(this);
/* strip out special_objects data which is set on startup anyway */
for(cell i = 0; i < special_object_count; i++)
#define OPEN_READ(path) _wfopen((path),L"rb")
#define OPEN_WRITE(path) _wfopen((path),L"wb")
-#define MOVE_FILE(path1,path2) \
+#define MOVE_FILE(path1,path2)\
do {\
- if(MoveFile((path1),(path2)) == 0)\
- general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object,NULL);\
+ if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false)\
+ std::cout << "MoveFile() failed: error " << GetLastError() << std::endl;\
} while(0)
/* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */