本文整理汇总了C++中save_file函数的典型用法代码示例。如果您正苦于以下问题:C++ save_file函数的具体用法?C++ save_file怎么用?C++ save_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Attribute
bool XUI_Window::SaveToXMLNode( TiXmlNode* pNode )
{
TiXmlElement* pElement = pNode->ToElement();
TiXmlElement Attribute( "attribute" );
if( save_file( &Attribute ) == false ) return false;
pNode->InsertEndChild( Attribute );
std::vector<XUI_Wnd*>::const_iterator citer = m_pChildren.begin();
while( citer != m_pChildren.end() )
{
XUI_Wnd* pXUI_Wnd = *citer;
TiXmlElement XmlElement("control");
XmlElement.SetAttribute( "lable", typeid( pXUI_Wnd ).name() );
if( typeid( pXUI_Wnd ) == typeid(XUI_Window) )
((XUI_Window*)pXUI_Wnd)->SaveToXMLNode( (TiXmlNode*)&XmlElement );
else
{
//if( pXUI_Wnd->SavePropertys( &XmlElement ) == false ) return false;
TiXmlElement Attribute( "attribute" );
if( pXUI_Wnd->save_file( &Attribute ) == false ) return false;
XmlElement.InsertEndChild( Attribute );
}
pNode->InsertEndChild( XmlElement );
++citer;
}
return true;
}
示例2: save_window_ok_button_callback
si_t save_window_ok_button_callback(void* btn, void* msg)
{
union message* m = (union message*)msg;
switch(m->base.type)
{
case MESSAGE_TYPE_MOUSE_SINGLE_CLICK:
if(0 == save_file(text_line_get_buf(save_text_line), text_line_get_buf(file_context_text_line)))
{
sprintf(log_label->text, "save successfully!");
}
else
{
sprintf(log_label->text, "failed to save file!");
}
application_del_window(save_window);
sprintf(file_label->text, "%s", text_line_get_buf(save_text_line));
save_window = NULL;
save_text_line = NULL;
break;
default:
button_default_callback(btn, msg);
return 0;
break;
}
label_repaint(log_label);
label_show(log_label);
return 0;
}
示例3: write_file
int
write_file(char *file)
{
int return_val = OK;
if (ignore_prev == 1)
/* if user wants to ignore previous version, we remove it *
* ( fcron daemon remove files no longer wanted before
* adding new ones ) */
remove_fcrontab(0);
if ( file_base->cf_line_base == NULL ) {
/* no entries */
explain("%s's fcrontab contains no entries : removed.", user);
remove_fcrontab(0);
}
else {
/* write the binary fcrontab on disk */
snprintf(buf, sizeof(buf), "new.%s", user);
if ( save_file(buf) != OK )
return_val = ERR;
}
/* copy original file to fcrontabs dir */
snprintf(buf, sizeof(buf), "%s.orig", user);
if ( copy(file, buf) == ERR )
return_val = ERR;
return return_val;
}
示例4: target_cm0p_read
//-----------------------------------------------------------------------------
static void target_cm0p_read(char *name)
{
uint32_t size = device->flash_size;
uint32_t addr = device->flash_start;
uint32_t offs = 0;
uint8_t *buf;
if (dap_read_word(DSU_CTRL_STATUS) & 0x00010000)
error_exit("devices is locked, unable to read");
buf = buf_alloc(device->flash_size);
verbose("Reading...");
while (size)
{
dap_read_block(addr, &buf[offs], device->row_size);
addr += device->row_size;
offs += device->row_size;
size -= device->row_size;
verbose(".");
}
save_file(name, buf, device->flash_size);
buf_free(buf);
verbose(" done.\n");
}
示例5: main
main ()
{
load_file (IN_FILE);
code_file ();
save_file (OUT_FILE);
free_mem ();
}
示例6: scramble
static int
scramble (const char *src, uint32_t sz, char *dst)
{
unsigned char *ptr = NULL;
FILE *fh;
if ((fh = fopen (src, "rb")) == NULL)
return -1;
if ((ptr = (unsigned char *) malloc (sz)) == NULL)
return -1;
if (fread (ptr, 1, sz, fh) != sz)
return -1;
fclose (fh);
if (!(fh == fopen (dst, "wb")))
return -1;
save_file (fh, ptr, sz);
fclose (fh);
free (ptr);
return 0;
}
示例7: get_next_line
int get_next_line(int const fd, char **line)
{
static t_list *file;
unsigned int index;
char *content;
if (!line || fd < 0 || fd == 1)
return (-1);
if ((!file || fd == 0) && (file = ft_lstnew(NULL, 0)))
if ((save_file(fd, &file)) < 1)
return (-1);
*line = "\0";
while (file)
{
index = 0;
content = file->content;
while (content[index] && content[index] != '\n')
index++;
*line = ft_strjoin(*line, ft_strsub(content, 0, index));
if (content[index] == '\n' && content[index + 1])
return (file->content = &content[index + 1], 1);
else if ((content[index] == '\n' && !content[index + 1]) || !file->next)
return (file = file->next, 1);
file = file->next;
}
return (0);
}
示例8: e_book_backend_vcf_dispose
static void
e_book_backend_vcf_dispose (GObject *object)
{
EBookBackendVCF *bvcf;
bvcf = E_BOOK_BACKEND_VCF (object);
if (bvcf->priv) {
g_mutex_lock (bvcf->priv->mutex);
if (bvcf->priv->flush_timeout_tag) {
g_source_remove (bvcf->priv->flush_timeout_tag);
bvcf->priv->flush_timeout_tag = 0;
}
if (bvcf->priv->dirty)
save_file (bvcf);
g_hash_table_destroy (bvcf->priv->contacts);
g_list_foreach (bvcf->priv->contact_list, (GFunc)g_free, NULL);
g_list_free (bvcf->priv->contact_list);
g_free (bvcf->priv->filename);
g_mutex_unlock (bvcf->priv->mutex);
g_mutex_free (bvcf->priv->mutex);
g_free (bvcf->priv);
bvcf->priv = NULL;
}
G_OBJECT_CLASS (e_book_backend_vcf_parent_class)->dispose (object);
}
示例9: exists
void save_settings::save(error_code& ec) const
{
// back-up current settings file as .bak before saving the new one
std::string backup = m_settings_file + ".bak";
bool has_settings = exists(m_settings_file);
bool has_backup = exists(backup);
if (has_settings && has_backup)
remove(backup, ec);
if (has_settings)
rename(m_settings_file, backup, ec);
ec.clear();
entry sett;
m_ses.save_state(sett);
for (std::map<std::string, int>::const_iterator i = m_ints.begin()
, end(m_ints.end()); i != end; ++i)
{
sett[i->first] = i->second;
}
for (std::map<std::string, std::string>::const_iterator i = m_strings.begin()
, end(m_strings.end()); i != end; ++i)
{
sett[i->first] = i->second;
}
std::vector<char> buf;
bencode(std::back_inserter(buf), sett);
save_file(m_settings_file, buf, ec);
}
示例10: access
log::log(string filename=string("all.log"))
{
int ret = access("log",0);
if(ret == -1)
#ifdef WINDOWSCODE
mkdir("log");
#else
mkdir("log", 0777);
#endif
if(m_fp==NULL)
{
//m_fp=fopen(filename.c_str(), "a");
//日志文件打开的模式 对文件的大小是否变换起决定性的作用, a方式 一直会增大,
if(access("all.log", 0) == 0)
save_file();
m_fp=fopen(filename.c_str(), "wb");
if(m_fp==NULL)
{
printf("open file error \n");
exit(-1);
}
}
}
示例11: file_check_data
static void file_check_data( struct file_info *file,
int fd,
struct write_info *w)
{
size_t remains, block, i;
off_t r;
char buf[BUFFER_SIZE];
srand(w->random_seed);
for (r = 0; r < w->random_offset; ++r)
rand();
CHECK(lseek(fd, w->offset, SEEK_SET) != (off_t) -1);
remains = w->size;
while (remains) {
if (remains > BUFFER_SIZE)
block = BUFFER_SIZE;
else
block = remains;
CHECK(read(fd, buf, block) == block);
for (i = 0; i < block; ++i) {
char c = (char) rand();
if (buf[i] != c) {
fprintf(stderr, "file_check_data failed at %u "
"checking data at %u size %u\n",
(unsigned) (w->size - remains + i),
(unsigned) w->offset,
(unsigned) w->size);
file_info_display(file);
save_file(fd, file);
}
CHECK(buf[i] == c);
}
remains -= block;
}
}
示例12: file_check_hole
static void file_check_hole( struct file_info *file,
int fd, off_t offset,
size_t size)
{
size_t remains, block, i;
char buf[BUFFER_SIZE];
CHECK(lseek(fd, offset, SEEK_SET) != (off_t) -1);
remains = size;
while (remains) {
if (remains > BUFFER_SIZE)
block = BUFFER_SIZE;
else
block = remains;
CHECK(read(fd, buf, block) == block);
for (i = 0; i < block; ++i) {
if (buf[i] != 0) {
fprintf(stderr, "file_check_hole failed at %u "
"checking hole at %u size %u\n",
(unsigned) (size - remains + i),
(unsigned) offset,
(unsigned) size);
file_info_display(file);
save_file(fd, file);
}
CHECK(buf[i] == 0);
}
remains -= block;
}
}
示例13: pce_shutdown
void pce_shutdown(void)
{
if(save_bram) save_file("pce.brm", bram, 0x2000);
#ifdef DEBUG
error("PC:%04X\n", h6280_get_pc());
#endif
}
示例14: mlx_name
mlx_name()
{
int nblocks,block;
GLOBRECORD *blockptr[MAXNBLOCKS+1];
long addr[32],leng[32]; /* oversized */
/* load multi-block file containing block to be renamed */
Dsetdrv(mlt_drive); dsetpath(mlt_path);
if (!readdatafile(MLXNAMTITL,mlxfile,mlxpath,MLX_EXT,0)) return;
mlt_drive= Dgetdrv(); Dgetpath(mlt_path,mlt_drive+1);
mlx_mem= tempmem;
/* choose block from it */
nblocks= scan_blocks(heap[mlx_mem].start,blockptr);
if (!nblocks) return; /* can't happen? */
block= select_block(BLOCK2NAM,nblocks,blockptr);
if ( (block<0) || (block>=nblocks) ) return;
/* edit the comment field in the selected block, and replace file
without warning */
if (_mlx_name(blockptr[block]->comment))
{
addr[0]= heap[mlx_mem].start;
leng[0]= heap[mlx_mem].nbytes;
save_file(mlxfile,mlxpath,-1,addr,leng);
}
} /* end mlx_name() */
示例15: save_file
void
GIFFManager::save_file(TArray<char> & data)
{
GP<ByteStream> gstr=ByteStream::create();
save_file(gstr);
data=gstr->get_data();
}