//------------------------------------------------------------------------------ bool save( const std::string& file_name ) { std::ofstream f( file_name.c_str(), std::ios::out | std::ios::binary ); if ( !f ) { return false; } bool is_still_good = true; // Define layout specific header fields // The position of the segment table is fixed after the header. // The position of the section table is variable and needs to be fixed // before saving. header->set_segments_num( segments.size() ); header->set_segments_offset( segments.size() ? header->get_header_size() : 0 ); header->set_sections_num( sections.size() ); header->set_sections_offset( 0 ); // Layout the first section right after the segment table current_file_pos = header->get_header_size() + header->get_segment_entry_size() * header->get_segments_num(); is_still_good = layout_segments_and_their_sections(); is_still_good = is_still_good && layout_sections_without_segments(); is_still_good = is_still_good && layout_section_table(); is_still_good = is_still_good && save_header( f ); is_still_good = is_still_good && save_sections( f ); is_still_good = is_still_good && save_segments( f ); f.close(); return is_still_good; }
void save(std::string filename) { FILE* fout = fopen(filename.c_str(), "wb"); if (fout == NULL) { throw FLANNException("Cannot open file"); } save_header(fout, *nnIndex_); saveIndex(fout); fclose(fout); }
static int check_part_gpt(disk_t *disk, const int verbose,partition_t *partition, const int saveheader) { int ret=0; unsigned int old_levels; old_levels=log_set_levels(0); if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_MS_BASIC_DATA)==0 || guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_MS_RESERVED)==0) { ret=check_FAT(disk,partition,verbose); if(ret!=0) ret=check_EXFAT(disk, partition); if(ret!=0) ret=check_NTFS(disk,partition,verbose,0); if(ret!=0) ret=check_ReFS(disk, partition); if(ret!=0) ret=check_linux(disk, partition, verbose); if(ret!=0) screen_buffer_add("No FAT, NTFS, ext2, JFS, Reiser, cramfs or XFS marker\n"); } else if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_LINUX_RAID)==0) { ret=check_MD(disk, partition, verbose); if(ret!=0) screen_buffer_add("Invalid RAID superblock\n"); } else if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_LINUX_LVM)==0) { ret=check_LVM(disk, partition, verbose); if(ret!=0) ret=check_LVM2(disk, partition, verbose); if(ret!=0) screen_buffer_add("No LVM or LVM2 structure\n"); } else if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_MAC_HFS)==0) { ret=check_HFS(disk, partition, verbose); if(ret!=0) ret=check_HFSP(disk, partition, verbose); if(ret!=0) screen_buffer_add("No HFS or HFS+ structure\n"); } log_set_levels(old_levels); if(ret!=0) { log_error("check_part_gpt failed for partition\n"); log_partition(disk, partition); aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk,partition); if(saveheader>0) { save_header(disk, partition, verbose); } } return ret; }
int main(int argc, const char* argv[]) { std::cout << "argc = " << argc << std::endl; for (auto i = 0u; i < argc; ++i) { std::cout << argv[i] << std::endl; } BMP bmp; load_bmp(bmp, argv[1]); show_bmp_data(bmp); convert_to_16bpp(bmp); save_header(bmp, argv[1]); nice(); return 0; }
//------------------------------------------------------------------------------ bool save( const std::string& file_name ) { std::ofstream f( file_name.c_str(), std::ios::out | std::ios::binary ); if ( !f ) { return false; } bool is_still_good = true; fill_final_attributes(); set_current_file_position(); is_still_good = is_still_good && save_header( f ); is_still_good = is_still_good && save_sections_without_segments( f ); is_still_good = is_still_good && save_segments_and_their_sections( f ); f.close(); return is_still_good; }
// used for copying automation alone int Track::copy_automation(double selectionstart, double selectionend, FileXML *file, int default_only, int active_only) { int64_t start = to_units(selectionstart, 0); int64_t end = to_units(selectionend, 0); file->tag.set_title("TRACK"); // Video or audio save_header(file); file->append_tag(); file->append_newline(); automation->copy(start, end, file, default_only, active_only); if(edl->session->auto_conf->plugins) { for(int i = 0; i < plugin_set.total; i++) { plugin_set.values[i]->copy_keyframes(start, end, file, default_only, active_only); } } file->tag.set_title("/TRACK"); file->append_tag(); file->append_newline(); file->append_newline(); file->append_newline(); file->append_newline(); return 0; }
/* Parse HTTP header and set appropriate env variables */ int parse_msghdr(UPNP_CONTEXT *context, struct upnp_method *methods) { char *token, *value; char *p; int i; /* skip the first line (method, url, and HTTP version), which we already processed */ for (i = 1; i < context->header_num; i++) { token = context->msghdrs[i]; strtok_r(token, ":", &value); /* skip white spaces */ while (*token == '\t' || *token == ' ') token++; if (value != NULL) { /* skip white spaces */ while (*value == '\t' || *value == ' ') value++; /* capitalize token */ for (p = token; *p; p++) *p = toupper(*p); save_header(context, token, value); } else { upnp_syslog(LOG_ERR, "Null value in parse_msghdr()"); goto error_out; } } return 0; error_out: context->status = R_ERROR; return -1; }
int Track::copy(double start, double end, FileXML *file, const char *output_path) { // Use a copy of the selection in converted units // So copy_automation doesn't reconvert. int64_t start_unit = to_units(start, 0); int64_t end_unit = to_units(end, 1); file->tag.set_title("TRACK"); file->tag.set_property("RECORD", record); file->tag.set_property("NUDGE", nudge); file->tag.set_property("PLAY", play); file->tag.set_property("GANG", gang); file->tag.set_property("DRAW", draw); file->tag.set_property("EXPAND", expand_view); file->tag.set_property("TRACK_W", track_w); file->tag.set_property("TRACK_H", track_h); save_header(file); file->append_tag(); file->append_newline(); save_derived(file); file->tag.set_title("TITLE"); file->append_tag(); file->append_text(title); file->tag.set_title("/TITLE"); file->append_tag(); file->append_newline(); // if(data_type == TRACK_AUDIO) // file->tag.set_property("TYPE", "AUDIO"); // else // file->tag.set_property("TYPE", "VIDEO"); // // file->append_tag(); // file->append_newline(); edits->copy(start_unit, end_unit, file, output_path); AutoConf auto_conf; auto_conf.set_all(1); automation->copy(start_unit, end_unit, file, 0, 0); for(int i = 0; i < plugin_set.total; i++) { plugin_set.values[i]->copy(start_unit, end_unit, file); } copy_derived(start_unit, end_unit, file); file->tag.set_title("/TRACK"); file->append_tag(); file->append_newline(); file->append_newline(); file->append_newline(); file->append_newline(); return 0; }