本文整理汇总了C++中core_fclose函数的典型用法代码示例。如果您正苦于以下问题:C++ core_fclose函数的具体用法?C++ core_fclose怎么用?C++ core_fclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了core_fclose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: core_fload
file_error core_fload(const char *filename, dynamic_buffer &data)
{
core_file *file = NULL;
file_error err;
UINT64 size;
/* attempt to open the file */
err = core_fopen(filename, OPEN_FLAG_READ, &file);
if (err != FILERR_NONE)
return err;
/* get the size */
size = core_fsize(file);
if ((UINT32)size != size)
{
core_fclose(file);
return FILERR_OUT_OF_MEMORY;
}
/* allocate memory */
data.resize(size);
/* read the data */
if (core_fread(file, &data[0], size) != size)
{
core_fclose(file);
data.clear();
return FILERR_FAILURE;
}
/* close the file and return data */
core_fclose(file);
return FILERR_NONE;
}
示例2: core_fclose
void device_image_interface::clear()
{
if (m_mame_file)
{
m_mame_file = nullptr;
m_file = nullptr;
} else {
if (m_file)
{
core_fclose(m_file);
m_file = nullptr;
}
}
m_image_name.clear();
m_readonly = false;
m_created = false;
m_longname.clear();
m_manufacturer.clear();
m_year.clear();
m_basename.clear();
m_basename_noext.clear();
m_filetype.clear();
m_full_software_name.clear();
m_software_info_ptr = nullptr;
m_software_part_ptr = nullptr;
m_software_list_name.clear();
}
示例3: _7z_file_close
void emu_file::close()
{
// close files and free memory
if (m__7zfile != nullptr)
_7z_file_close(m__7zfile);
m__7zfile = nullptr;
if (m_zipfile != nullptr)
zip_file_close(m_zipfile);
m_zipfile = nullptr;
if (m_file != nullptr)
core_fclose(m_file);
m_file = nullptr;
m__7zdata.clear();
m_zipdata.clear();
if (m_remove_on_close)
osd_rmfile(m_fullpath.c_str());
m_remove_on_close = false;
// reset our hashes and path as well
m_hashes.reset();
m_fullpath.clear();
}
示例4: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, std::string &templatefile, std::string &title)
{
std::string modified(templatefile);
strreplace(modified, "<!--TITLE-->", title.c_str());
core_fwrite(file, modified.c_str(), modified.length());
core_fclose(file);
}
示例5: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &path)
{
astring modified(templatefile);
modified.replace(0, "<!--PATH-->", path.cstr());
core_fwrite(file, modified.cstr(), modified.len());
core_fclose(file);
}
示例6: stream_close
void stream_close(imgtool_stream *s)
{
assert(s != NULL);
switch(s->imgtype)
{
case IMG_FILE:
if (s->u.file != NULL)
{
core_fclose(s->u.file);
s->u.file = NULL;
}
break;
case IMG_MEM:
if (s->u.buffer != NULL)
{
free(s->u.buffer);
s->u.buffer = NULL;
}
break;
default:
assert(0);
break;
}
free((void *) s);
}
示例7: zippath_fopen
floppy_image_format_t *floppy_image_device::identify(std::string filename)
{
core_file *fd;
std::string revised_path;
file_error err = zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
if(err) {
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to open the image file");
return 0;
}
io_generic io;
io.file = fd;
io.procs = &corefile_ioprocs_noclose;
io.filler = 0xff;
int best = 0;
floppy_image_format_t *best_format = 0;
for(floppy_image_format_t *format = fif_list; format; format = format->next) {
int score = format->identify(&io, form_factor);
if(score > best) {
best = score;
best_format = format;
}
}
core_fclose(fd);
return best_format;
}
示例8: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &title)
{
astring modified(templatefile);
modified.replace(0, "<!--TITLE-->", title.c_str());
core_fwrite(file, modified.c_str(), modified.len());
core_fclose(file);
}
示例9: global_free
void device_image_interface::clear()
{
if (m_mame_file)
{
global_free(m_mame_file);
m_mame_file = NULL;
m_file = NULL;
} else {
if (m_file)
{
core_fclose(m_file);
m_file = NULL;
}
}
m_image_name.reset();
m_readonly = false;
m_created = false;
m_longname.reset();
m_manufacturer.reset();
m_year.reset();
m_basename.reset();
m_basename_noext.reset();
m_filetype.reset();
m_full_software_name = NULL;
m_software_info_ptr = NULL;
m_software_part_ptr = NULL;
m_software_list_name = NULL;
}
示例10: mame_fclose
void legacy_image_device_base::clear()
{
if (m_mame_file)
{
mame_fclose(m_mame_file);
m_mame_file = NULL;
m_file = NULL;
} else {
if (m_file)
{
core_fclose(m_file);
m_file = NULL;
}
}
m_name.reset();
m_writeable = FALSE;
m_created = FALSE;
m_longname.reset();
m_manufacturer.reset();
m_year.reset();
m_playable.reset();
m_extrainfo.reset();
m_basename_noext.reset();
m_filetype.reset();
m_full_software_name = NULL;
m_software_info_ptr = NULL;
m_software_part_ptr = NULL;
}
示例11: _7z_file_close
void emu_file::close()
{
// close files and free memory
if (m__7zfile != NULL)
_7z_file_close(m__7zfile);
m__7zfile = NULL;
if (m_zipfile != NULL)
zip_file_close(m_zipfile);
m_zipfile = NULL;
if (m_file != NULL)
core_fclose(m_file);
m_file = NULL;
m__7zdata.reset();
m_zipdata.reset();
if (m_remove_on_close)
osd_rmfile(m_fullpath);
m_remove_on_close = false;
// reset our hashes and path as well
m_hashes.reset();
m_fullpath.reset();
}
示例12: astring_dup
static astring *find_include_file(int srcrootlen, const astring *srcfile, const astring *filename)
{
include_path *curpath;
/* iterate over include paths and find the file */
for (curpath = incpaths; curpath != NULL; curpath = curpath->next)
{
astring *srcincpath = astring_dup(curpath->path);
core_file *testfile;
int lastsepindex = 0;
int sepindex;
/* a '.' include path is specially treated */
if (astring_cmpc(curpath->path, ".") == 0)
astring_cpysubstr(srcincpath, srcfile, 0, astring_rchr(srcfile, 0, PATH_SEPARATOR[0]));
/* append the filename piecemeal to account for directories */
while ((sepindex = astring_chr(filename, lastsepindex, '/')) != -1)
{
astring *pathpart = astring_dupsubstr(filename, lastsepindex, sepindex - lastsepindex);
/* handle .. by removing a chunk from the incpath */
if (astring_cmpc(pathpart, "..") == 0)
{
int sepindex_part = astring_rchr(srcincpath, 0, PATH_SEPARATOR[0]);
if (sepindex_part != -1)
astring_substr(srcincpath, 0, sepindex_part);
}
/* otherwise, append a path separator and the pathpart */
else
astring_cat(astring_catc(srcincpath, PATH_SEPARATOR), pathpart);
/* advance past the previous index */
lastsepindex = sepindex + 1;
/* free the path part we extracted */
astring_free(pathpart);
}
/* now append the filename */
astring_catsubstr(astring_catc(srcincpath, PATH_SEPARATOR), filename, lastsepindex, -1);
/* see if we can open it */
if (core_fopen(astring_c(srcincpath), OPEN_FLAG_READ, &testfile) == FILERR_NONE)
{
/* close the file */
core_fclose(testfile);
return srcincpath;
}
/* free our include path */
astring_free(srcincpath);
}
return NULL;
}
示例13: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, const astring *templatefile, const astring *title)
{
astring *modified;
modified = astring_dup(templatefile);
astring_replacec(modified, 0, "<!--TITLE-->", astring_c(title));
core_fwrite(file, astring_c(modified), astring_len(modified));
astring_free(modified);
core_fclose(file);
}
示例14: check_file
static bool check_file(astring &srcincpath)
{
// see if we can open it
core_file *testfile;
if (core_fopen(srcincpath, OPEN_FLAG_READ, &testfile) == FILERR_NONE)
{
// close the file
core_fclose(testfile);
return true;
}
return false;
}
示例15: core_fclose
int device_image_interface::reopen_for_write(const char *path)
{
if(m_file)
core_fclose(m_file);
file_error filerr = FILERR_NOT_FOUND;
image_error_t err = IMAGE_ERROR_FILENOTFOUND;
astring revised_path;
/* attempt to open the file for writing*/
filerr = zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path);
/* did the open succeed? */
switch(filerr)
{
case FILERR_NONE:
/* success! */
m_readonly = 0;
m_created = 1;
err = IMAGE_ERROR_SUCCESS;
break;
case FILERR_NOT_FOUND:
case FILERR_ACCESS_DENIED:
/* file not found (or otherwise cannot open); continue */
err = IMAGE_ERROR_FILENOTFOUND;
break;
case FILERR_OUT_OF_MEMORY:
/* out of memory */
err = IMAGE_ERROR_OUTOFMEMORY;
break;
case FILERR_ALREADY_OPEN:
/* this shouldn't happen */
err = IMAGE_ERROR_ALREADYOPEN;
break;
case FILERR_FAILURE:
case FILERR_TOO_MANY_FILES:
case FILERR_INVALID_DATA:
default:
/* other errors */
err = IMAGE_ERROR_INTERNAL;
break;
}
/* if successful, set the file name */
if (filerr == FILERR_NONE)
set_image_filename(revised_path);
return err;
}