static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd) { astring fname(ROM_GETNAME(romp), ".dif"); /* try to open the diff */ LOG(("Opening differencing image file: %s\n", fname.cstr())); emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE); file_error filerr = diff_file.open(fname); if (filerr == FILERR_NONE) { astring fullpath(diff_file.fullpath()); diff_file.close(); LOG(("Opening differencing image file: %s\n", fullpath.cstr())); return diff_chd.open(fullpath, true, &source); } /* didn't work; try creating it instead */ LOG(("Creating differencing image: %s\n", fname.cstr())); diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); filerr = diff_file.open(fname); if (filerr == FILERR_NONE) { astring fullpath(diff_file.fullpath()); diff_file.close(); /* create the CHD */ LOG(("Creating differencing image file: %s\n", fullpath.cstr())); chd_codec_type compression[4] = { CHD_CODEC_NONE }; chd_error err = diff_chd.create(fullpath, source.logical_bytes(), source.hunk_bytes(), compression, source); if (err != CHDERR_NONE) return err; return diff_chd.clone_all_metadata(source); } return CHDERR_FILE_NOT_FOUND; }
static chd_error open_disk_diff(emu_options &options, const char *name, chd_file &source, chd_file &diff_chd) { std::string fname = std::string(name).append(".dif"); /* try to open the diff */ //printf("Opening differencing image file: %s\n", fname.c_str()); emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE); osd_file::error filerr = diff_file.open(fname.c_str()); if (filerr == osd_file::error::NONE) { std::string fullpath(diff_file.fullpath()); diff_file.close(); //printf("Opening differencing image file: %s\n", fullpath.c_str()); return diff_chd.open(fullpath.c_str(), true, &source); } /* didn't work; try creating it instead */ //printf("Creating differencing image: %s\n", fname.c_str()); diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); filerr = diff_file.open(fname.c_str()); if (filerr == osd_file::error::NONE) { std::string fullpath(diff_file.fullpath()); diff_file.close(); /* create the CHD */ //printf("Creating differencing image file: %s\n", fupointllpath.c_str()); chd_codec_type compression[4] = { CHD_CODEC_NONE }; chd_error err = diff_chd.create(fullpath.c_str(), source.logical_bytes(), source.hunk_bytes(), compression, source); if (err != CHDERR_NONE) return err; return diff_chd.clone_all_metadata(source); } return CHDERR_FILE_NOT_FOUND; }
static chd_error create_chd(chd_file_compressor &file, const char *filename, chd_file &source, const movie_info &info) { // create the file chd_codec_type compression[4] = { CHD_CODEC_AVHUFF }; chd_error chderr = file.create(filename, source.logical_bytes(), source.hunk_bytes(), source.unit_bytes(), compression); if (chderr != CHDERR_NONE) { fprintf(stderr, "Error creating new CHD file: %s\n", chd_file::error_string(chderr)); return chderr; } // clone the metadata chderr = file.clone_all_metadata(source); if (chderr != CHDERR_NONE) { fprintf(stderr, "Error cloning metadata: %s\n", chd_file::error_string(chderr)); return chderr; } // begin compressing file.compress_begin(); return CHDERR_NONE; }