本文整理汇总了C++中FileIO::read方法的典型用法代码示例。如果您正苦于以下问题:C++ FileIO::read方法的具体用法?C++ FileIO::read怎么用?C++ FileIO::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO::read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImageOpen
void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
{
//MemoryStream fp(new FileStream(path, FileStream::MODE_READ));
FileIO fp;
fp.open(path);
if(!fp)
{
throw MDFN_Error(0, "Error opening file \"%s\"", path);
}
static const unsigned max_args = 4;
std::string linebuf;
std::string cmdbuf, args[max_args];
bool IsTOC = FALSE;
int32 active_track = -1;
int32 AutoTrackInc = 1; // For TOC
CDRFILE_TRACK_INFO TmpTrack;
std::string file_base, file_ext;
std::map<std::string, std::shared_ptr<FileIO>> toc_streamcache;
disc_type = DISC_TYPE_CDDA_OR_M1;
TmpTrack = {};
MDFN_GetFilePathComponents(path, &base_dir, &file_base, &file_ext);
if(!strcasecmp(file_ext.c_str(), ".toc"))
{
MDFN_printf(_("TOC file detected.\n"));
IsTOC = true;
}
// Check for annoying UTF-8 BOM.
if(!IsTOC)
{
uint8 bom_tmp[3];
if(fp.read(bom_tmp, 3) == 3 && bom_tmp[0] == 0xEF && bom_tmp[1] == 0xBB && bom_tmp[2] == 0xBF)
{
// Print an annoying error message, but don't actually error out.
MDFN_PrintError(_("UTF-8 BOM detected at start of CUE sheet."));
}
else
fp.seekS(0);
}
// Assign opposite maximum values so our tests will work!
FirstTrack = 99;
LastTrack = 0;
linebuf.reserve(1024);
while(get_line(fp, linebuf) >= 0)
{
unsigned argcount = 0;
if(IsTOC)
{
// Handle TOC format comments
size_t ss_loc = linebuf.find("//");
if(ss_loc != std::string::npos)
linebuf.resize(ss_loc);
}
// Call trim AFTER we handle TOC-style comments, so we'll be sure to remove trailing whitespace in lines like: MONKEY // BABIES
MDFN_trim(linebuf);
if(linebuf.length() == 0) // Skip blank lines.
continue;
// Grab command and arguments.
{
size_t offs = 0;
offs = UnQuotify(linebuf, offs, cmdbuf, false);
for(argcount = 0; argcount < max_args && offs < linebuf.length(); argcount++)
offs = UnQuotify(linebuf, offs, args[argcount]);
// Make sure unused arguments are cleared out so we don't have inter-line leaks!
for(unsigned x = argcount; x < max_args; x++)
args[x].clear();
MDFN_strtoupper(cmdbuf);
}
//printf("%s\n", cmdbuf.c_str()); //: %s %s %s %s\n", cmdbuf.c_str(), args[0].c_str(), args[1].c_str(), args[2].c_str(), args[3].c_str());
if(IsTOC)
{
if(cmdbuf == "TRACK")
{
if(active_track >= 0)
{
Tracks[active_track] = TmpTrack;
TmpTrack = {};
active_track = -1;
}
if(AutoTrackInc > 99)
{
throw(MDFN_Error(0, _("Invalid track number: %d"), AutoTrackInc));
//.........这里部分代码省略.........