本文整理汇总了C++中FileXML::write_to_file方法的典型用法代码示例。如果您正苦于以下问题:C++ FileXML::write_to_file方法的具体用法?C++ FileXML::write_to_file怎么用?C++ FileXML::write_to_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileXML
的用法示例。
在下文中一共展示了FileXML::write_to_file方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_jobs
void BatchRenderThread::save_jobs(char *path)
{
FileXML file;
for(int i = 0; i < jobs.total; i++)
{
file.tag.set_title("JOB");
jobs.values[i]->save(&file);
}
if(path[0])
file.write_to_file(path);
else
file.write_to_file(create_path(path));
}
示例2: fopen
int Commercials::
write_ads(const char *filename)
{
char index_filename[BCTEXTLEN], source_filename[BCTEXTLEN];
IndexFile::get_index_filename(source_filename,
mwindow->preferences->index_directory, index_filename,
filename, ".ads");
FILE *fp = fopen(index_filename, "wb");
if( fp != 0 ) {
FileXML xml;
xml.tag.set_title("ADS");
xml.append_tag();
xml.append_newline();
int trks = tracks.size();
for( int trk=0; trk<trks; ++trk )
tracks.get(trk)->save(xml);
xml.tag.set_title("/ADS");
xml.append_tag();
xml.append_newline();
xml.terminate_string();
xml.write_to_file(fp);
fclose(fp);
}
return 0;
}
示例3: write_index
int IndexState::write_index(const char *path,
int data_bytes,
Asset *asset,
int64_t length_source)
{
FILE *file;
if(!(file = fopen(path, "wb")))
{
// failed to create it
printf(_("IndexState::write_index Couldn't write index file %s to disk.\n"),
path);
}
else
{
FileXML xml;
// Pad index start position
fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
index_status = INDEX_READY;
// Write asset encoding information in index file.
// This also calls back into index_state to write it.
if(asset)
{
asset->write(&xml,
1,
"");
}
else
{
// Must write index_state directly.
write_xml(&xml);
}
xml.write_to_file(file);
index_start = ftell(file);
fseek(file, 0, SEEK_SET);
// Write index start
fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
fseek(file, index_start, SEEK_SET);
// Write index data
fwrite(index_buffer,
data_bytes,
1,
file);
fclose(file);
}
// Force reread of header
index_status = INDEX_NOTTESTED;
index_end = length_source;
old_index_end = 0;
index_start = 0;
return 0;
}
示例4: handle_event
int Save::handle_event()
{
if(mwindow->session->filename[0] == 0)
{
saveas->start();
}
else
{
// save it
// TODO: Move this into mwindow.
FileXML file;
mwindow->edl->save_xml(&file,
mwindow->session->filename,
0,
0);
file.terminate_string();
if(file.write_to_file(mwindow->session->filename))
{
char string2[256];
sprintf(string2, _("Couldn't open %s"), mwindow->session->filename);
ErrorBox error(PROGRAM_NAME ": Error",
mwindow->gui->get_abs_cursor_x(1),
mwindow->gui->get_abs_cursor_y(1));
error.create_objects(string2);
error.raise_window();
error.run_window();
return 1;
}
else
{
char string[BCTEXTLEN];
sprintf(string,
_("\"%s\" %dC written"),
mwindow->session->filename,
(int)strlen(file.string));
mwindow->gui->show_message(string);
}
mwindow->session->changes_made = 0;
// Last command in program
// if(saveas->quit_now) mwindow->gui->set_done(0);
if(saveas->quit_now) mwindow->playback_3d->quit();
}
return 1;
}
示例5: save
void ChannelDB::save(const char *prefix)
{
char path[BCTEXTLEN];
FileXML file;
prefix_to_path(path, prefix);
if(channels.total)
{
for(int i = 0; i < channels.total; i++)
{
// Save channel here
channels.values[i]->save(&file);
}
file.terminate_string();
file.write_to_file(path);
}
}
示例6: write_index
void Asset::write_index(char *path, int data_bytes)
{
FILE *file;
if(!(file = fopen(path, "wb")))
{
// failed to create it
printf(_("Asset::write_index Couldn't write index file %s to disk.\n"), path);
}
else
{
FileXML xml;
// Pad index start position
fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
index_status = INDEX_READY;
// Write encoding information
write(&xml,
1,
"");
xml.write_to_file(file);
index_start = ftell(file);
fseek(file, 0, SEEK_SET);
// Write index start
fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
fseek(file, index_start, SEEK_SET);
// Write index data
fwrite(index_buffer,
data_bytes,
1,
file);
fclose(file);
}
// Force reread of header
index_status = INDEX_NOTTESTED;
// index_status = INDEX_READY;
index_end = audio_length;
old_index_end = 0;
index_start = 0;
}
示例7: run
void SaveAs::run()
{
// ======================================= get path from user
int result;
//printf("SaveAs::run 1\n");
char directory[1024], filename[1024];
sprintf(directory, "~");
mwindow->defaults->get("DIRECTORY", directory);
// Loop if file exists
do{
SaveFileWindow *window;
window = new SaveFileWindow(mwindow, directory);
window->lock_window("SaveAs::run");
window->create_objects();
window->unlock_window();
result = window->run_window();
mwindow->defaults->update("DIRECTORY", window->get_submitted_path());
strcpy(filename, window->get_submitted_path());
delete window;
// Extend the filename with .xml
if(strlen(filename) < 4 ||
strcasecmp(&filename[strlen(filename) - 4], ".xml"))
{
strcat(filename, ".xml");
}
// ======================================= try to save it
if(filename[0] == 0) return; // no filename given
if(result == 1) return; // user cancelled
result = ConfirmSave::test_file(mwindow, filename);
}while(result); // file exists so repeat
//printf("SaveAs::run 6 %s\n", filename);
// save it
FileXML file;
mwindow->gui->lock_window("SaveAs::run 1");
// update the project name
mwindow->set_filename(filename);
mwindow->edl->save_xml(&file,
filename,
0,
0);
mwindow->gui->unlock_window();
file.terminate_string();
if(file.write_to_file(filename))
{
char string2[256];
mwindow->set_filename(""); // update the project name
sprintf(string2, _("Couldn't open %s."), filename);
ErrorBox error(PROGRAM_NAME ": Error",
mwindow->gui->get_abs_cursor_x(1),
mwindow->gui->get_abs_cursor_y(1));
error.create_objects(string2);
error.raise_window();
error.run_window();
return;
}
else
{
char string[BCTEXTLEN];
sprintf(string, _("\"%s\" %dC written"), filename, (int)strlen(file.string));
mwindow->gui->lock_window("SaveAs::run 2");
mwindow->gui->show_message(string);
mwindow->gui->unlock_window();
}
mwindow->session->changes_made = 0;
mmenu->add_load(filename);
// Last command in program
// if(quit_now) mwindow->gui->set_done(0);
if(quit_now) mwindow->playback_3d->quit();
return;
}