本文整理汇总了C++中FileReader::OpenFile方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::OpenFile方法的具体用法?C++ FileReader::OpenFile怎么用?C++ FileReader::OpenFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::OpenFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MultiFileReader
TsStreamFileSource*
TsStreamFileSource::createNew(UsageEnvironment& env, wchar_t const* fileName,
unsigned preferredFrameSize,
unsigned playTimePerFrame,
int channelType)
{
LogDebug(L"ts:open %s", fileName);
FileReader* reader;
if (wcsstr(fileName, L".tsbuffer")!=NULL)
{
//MultiFileReader::MultiFileReader(BOOL useFileNext, BOOL useDummyWrites, CCritSec* pFilterLock, BOOL useRandomAccess, BOOL extraLogging):
reader = new MultiFileReader(FALSE, FALSE, NULL, TRUE, FALSE);
reader->SetTimeshift(true);
}
else
{
reader = new FileReader();
reader->SetTimeshift(false);
}
reader->SetFileName(fileName);
reader->OpenFile();
Boolean deleteFidOnClose = true;
TsStreamFileSource* newSource = new TsStreamFileSource(env, (FILE*)reader, deleteFidOnClose, preferredFrameSize, playTimePerFrame, channelType);
__int64 fileSize = reader->GetFileSize();
if (fileSize < 0) fileSize = 0;
newSource->fFileSize = fileSize;
LogDebug("ts:size %I64d", fileSize);
return newSource;
}
示例2: LoadShader
// Public
bool Shader::LoadShader(const std::string& vertexShaderPath, const std::string& fragmentShaderPath)
{
if (!m_program)
{
//uth::Graphics::DestroyShaderProgram(m_program);
m_program = uth::Graphics::CreateShaderProgram();
}
FileReader fr;
// Vertex Shader
fr.OpenFile(vertexShaderPath);
#if defined(UTH_SYSTEM_OPENGLES)
const std::string vertex = "#version 100\n#define UTH_ES\n" + fr.ReadText();
#elif defined(UTH_SYSTEM_OPENGL)
const std::string vertex = "#version 100\n" + fr.ReadText();
#endif
if(!uth::Graphics::CreateShader(VERTEX_SHADER, m_program, vertex.c_str()))
{
WriteError("Vertex shader failed");
return false;
}
fr.CloseFile();
// Fragment Shader
fr.OpenFile(fragmentShaderPath);
#if defined(UTH_SYSTEM_OPENGLES)
const std::string fragment = "#version 100\n#define UTH_ES\nprecision mediump float;\n" + fr.ReadText();
#elif defined(UTH_SYSTEM_OPENGL)
const std::string fragment = "#version 100\nprecision mediump float;\n" + fr.ReadText();
#endif
if(!uth::Graphics::CreateShader(FRAGMENT_SHADER, m_program, fragment.c_str()))
{
WriteError("Fragment shader failed");
return false;
}
fr.CloseFile();
return uth::Graphics::LinkShaderProgram(m_program);
}
示例3: LoadFromFile
bool Font::LoadFromFile(const std::string& filePath)
{
FileReader fr;
fr.OpenFile(filePath);
m_fontData = fr.ReadBinary();
if (!m_fontData.ptr())
return false;
return true;
}
示例4: FillCache
int FDirectoryLump::FillCache()
{
FileReader fr;
Cache = new char[LumpSize];
if (!fr.OpenFile(mFullPath))
{
memset(Cache, 0, LumpSize);
return 0;
}
fr.Read(Cache, LumpSize);
RefCount = 1;
return 1;
}
示例5: OpenFile
bool FScanner::OpenFile (const char *name)
{
Close ();
FileReader fr;
if (!fr.OpenFile(name)) return false;
auto filesize = fr.GetLength();
auto filebuff = fr.Read();
if (filebuff.Size() == 0 && filesize > 0) return false;
ScriptBuffer = FString((const char *)filebuff.Data(), filesize);
ScriptName = name; // This is used for error messages so the full file name is preferable
LumpNum = -1;
PrepareScript ();
return true;
}
示例6: UnitTest
s32 FileReader::UnitTest(void)
{
s32 retVal = 0;
FileReader test;
test.ArchieveFilesFromFolder("ToShare");
test.PrintFiles();
istring f1 = test.GetFileName(1);
istring f2 = test.GetFileName(-1);
istring ft2 = test.GetFileName(test.GetFiles().size());
assertion(f2 == ft2);
test.OpenFile(4);
char knownSize[50] = {0};
char knownSize2[50] = {0};
s32 bytesRead = test.ReadFile(knownSize, 20);
s32 bytesRead2 = test.ReadFile(knownSize2, 30);
return retVal;
}
示例7: ReadSaveStrings
void FSavegameManager::ReadSaveStrings()
{
if (SaveGames.Size() == 0)
{
void *filefirst;
findstate_t c_file;
FString filter;
LastSaved = LastAccessed = -1;
quickSaveSlot = nullptr;
filter = G_BuildSaveName("*." SAVEGAME_EXT, -1);
filefirst = I_FindFirst(filter.GetChars(), &c_file);
if (filefirst != ((void *)(-1)))
{
do
{
// I_FindName only returns the file's name and not its full path
FString filepath = G_BuildSaveName(I_FindName(&c_file), -1);
FResourceFile *savegame = FResourceFile::OpenResourceFile(filepath, true, true);
if (savegame != nullptr)
{
bool oldVer = false;
bool missing = false;
FResourceLump *info = savegame->FindLump("info.json");
if (info == nullptr)
{
// savegame info not found. This is not a savegame so leave it alone.
delete savegame;
continue;
}
void *data = info->CacheLump();
FSerializer arc(nullptr);
if (arc.OpenReader((const char *)data, info->LumpSize))
{
int savever = 0;
arc("Save Version", savever);
FString engine = arc.GetString("Engine");
FString iwad = arc.GetString("Game WAD");
FString title = arc.GetString("Title");
if (engine.Compare(GAMESIG) != 0 || savever > SAVEVER)
{
// different engine or newer version:
// not our business. Leave it alone.
delete savegame;
continue;
}
if (savever < MINSAVEVER)
{
// old, incompatible savegame. List as not usable.
oldVer = true;
}
else if (iwad.CompareNoCase(Wads.GetWadName(Wads.GetIwadNum())) == 0)
{
missing = !G_CheckSaveGameWads(arc, false);
}
else
{
// different game. Skip this.
delete savegame;
continue;
}
FSaveGameNode *node = new FSaveGameNode;
node->Filename = filepath;
node->bOldVersion = oldVer;
node->bMissingWads = missing;
node->SaveTitle = title;
InsertSaveNode(node);
delete savegame;
}
}
else // check for old formats.
{
FileReader file;
if (file.OpenFile(filepath))
{
PNGHandle *png;
char sig[16];
char title[OLDSAVESTRINGSIZE + 1];
bool oldVer = true;
bool addIt = false;
bool missing = false;
// ZDoom 1.23 betas 21-33 have the savesig first.
// Earlier versions have the savesig second.
// Later versions have the savegame encapsulated inside a PNG.
//
// Old savegame versions are always added to the menu so
// the user can easily delete them if desired.
title[OLDSAVESTRINGSIZE] = 0;
if (nullptr != (png = M_VerifyPNG(file)))
{
char *ver = M_GetPNGText(png, "ZDoom Save Version");
//.........这里部分代码省略.........
示例8: Save
void PackageFile::Save(std::string savePath)
{
OutputFileName = savePath;
FileReader rdr;
int headerSize = HEADER_SIZE; // Header Size
int directorySize = 0; // Directory size
int bufPos = 0; // Data section size
auto it = filesList->GetContainer()->begin();
while (it != filesList->GetContainer()->end())
{
FileListEntry* fileListing = *it;
std::string fileName;
if (fileListing->RelativeDirectoryParentRoot == "")
{
fileName = fileListing->File->FileName;
}
else
{
fileName = StringSubtract(fileListing->File->FilePath, fileListing->RelativeDirectoryParentRoot);
}
rdr.OpenFile(fileListing->File->FilePath.c_str());
if (contents != NULL)
delete(contents);
contents = rdr.GetFileContents();
DirectoryEntry* newFileEntry = new DirectoryEntry();
strcpy(newFileEntry->fileName, const_cast<char*>(fileName.c_str()));
newFileEntry->fileLength = contents->fileSize;
newFileEntry->filePosition = bufPos;
newFileEntry->fileContents = new char[contents->fileSize];
memcpy(newFileEntry->fileContents, contents->buffer, contents->fileSize);
bufPos += contents->fileSize;
directorySize += sizeof(newFileEntry->fileName) + sizeof(newFileEntry->fileLength) + sizeof(newFileEntry->filePosition);
entries->Add(newFileEntry);
rdr.Close();
it++;
}
int fileSize = headerSize + bufPos + directorySize;
Header *packHeader = new Header();
strncpy(packHeader->sig, "PACK", 4);
packHeader->dirOffset = headerSize;
packHeader->dirLength = directorySize;
WriteBytes(packHeader->sig, 4, memStream);
WriteBytes((char*)&packHeader->dirOffset, 4, memStream);
WriteBytes((char*)&packHeader->dirLength, 4, memStream);
packageHeader = packHeader;
auto it2 = entries->GetContainer()->begin();
int currentDirectoryOffset = 0;
int currentDataSize = 0;
while (it2 != entries->GetContainer()->end())
{
DirectoryEntry* entry = *it2;
WriteBytes(entry->fileName, sizeof(entry->fileName), memStream);
int currPos = headerSize + directorySize + currentDataSize;
char* filePosCopy = new char[4];
memcpy(filePosCopy, (char*)&entry->filePosition, 4);
WriteBytes(filePosCopy, sizeof(filePosCopy), memStream);
char* fileLengthCopy = new char[4];
memcpy(fileLengthCopy, (char*)&entry->fileLength, 4);
WriteBytes(fileLengthCopy, sizeof(fileLengthCopy), memStream);
currentDataSize += entry->fileLength;
it2++;
}
auto it3 = entries->GetContainer()->begin();
while (it3 != entries->GetContainer()->end())
{
DirectoryEntry* entry = *it3;
WriteBytes(entry->fileContents, entry->fileLength, memStream);
it3++;
//.........这里部分代码省略.........
示例9: NewReader
FileReader FDirectoryLump::NewReader()
{
FileReader fr;
fr.OpenFile(mFullPath);
return fr;
}