当前位置: 首页>>代码示例>>C++>>正文


C++ CFileHandler类代码示例

本文整理汇总了C++中CFileHandler的典型用法代码示例。如果您正苦于以下问题:C++ CFileHandler类的具体用法?C++ CFileHandler怎么用?C++ CFileHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CFileHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CFileHandler

/** Called by the map-selecting CglList. */
void CPreGame::SelectMap(std::string s)
{
    if (s == "Random map") {
        s = pregame->showList->items[1 + gu->usRandInt() % (pregame->showList->items.size() - 1)];
    }
    stupidGlobalMapname = pregame->mapName = s;
    delete pregame->showList;
    pregame->showList = 0;
    logOutput << "Map: " << s.c_str() << "\n";

    // Determine if the map is inside an archive, and possibly map needed archives
    CFileHandler* f = SAFE_NEW CFileHandler("maps/" + s);
    if (!f->FileExists()) {
        vector<string> ars = archiveScanner->GetArchivesForMap(s);
        if (ars.empty())
            throw content_error("Couldn't find any archives for map '" + s + "'.");
        for (vector<string>::iterator i = ars.begin(); i != ars.end(); ++i) {
            if (!hpiHandler->AddArchive(*i, false))
                throw content_error("Couldn't load archive '" + *i + "' for map '" + s + "'.");
        }
    }
    delete f;

    if (net && net->GetDemoRecorder())
        net->GetDemoRecorder()->SetName(s);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:27,代码来源:PreGame.cpp

示例2: sizeof

bool CMouseCursor::BuildFromFileNames(const string& name, int lastFrame)
{
	// find the image file type to use
	const char* ext = "";
	const char* exts[] = { "png", "tga", "bmp" };
	const int extCount = sizeof(exts) / sizeof(exts[0]);
	for (int e = 0; e < extCount; e++) {
		ext = exts[e];
		std::ostringstream namebuf;
		namebuf << "anims/" << name << "_0." << ext;
		CFileHandler* f = new CFileHandler(namebuf.str());
		if (f->FileExists()) {
			delete f;
			break;
		}
		delete f;
	}

	while (int(frames.size()) < lastFrame) {
		std::ostringstream namebuf;
		namebuf << "anims/" << name << "_" << frames.size() << "." << ext;
		ImageData image;
		if (!LoadCursorImage(namebuf.str(), image))
			break;
		images.push_back(image);
		FrameData frame(image, defFrameLength);
		frames.push_back(frame);
	}

	hwCursor->Finish();

	return true;
}
开发者ID:DoctorEmmettBrown,项目名称:spring,代码行数:33,代码来源:MouseCursor.cpp

示例3: fh

int CAICallback::GetFileSize (const char *filename, const char* modes)
{
	CFileHandler fh (filename, modes);

	if (!fh.FileExists ())
		return -1;

	return fh.FileSize();
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:9,代码来源:AICallback.cpp

示例4: fh

int CAICallback::GetFileSize (const char *name)
{
	CFileHandler fh (name);

	if (!fh.FileExists ())
		return -1;

	return fh.FileSize();
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:9,代码来源:AICallback.cpp

示例5: CFileHandler

int CArchiveDir::OpenFile(const std::string& fileName)
{
	CFileHandler* f = SAFE_NEW CFileHandler(archiveName + lcNameToOrigName[StringToLower(fileName)]);

	if (!f || !f->FileExists())
		return 0;

	++curFileHandle;
	fileHandles[curFileHandle] = f;
	return curFileHandle;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:11,代码来源:ArchiveDir.cpp

示例6: GetLine

// returns next line (without newlines)
string SimpleParser::GetLine(CFileHandler& fh)
{
	lineNumber++;
	char a;
	string s = "";
	while (!fh.Eof()) {
		fh.Read(&a, 1);
		if (a == '\n') { break; }
		if (a != '\r') { s += a; }
	}
	return s;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:13,代码来源:SimpleParser.cpp

示例7:

string CUnit3DLoader::GetLine(CFileHandler& fh)
{
	string s="";
	char a;
	fh.Read(&a,1);
	while(a!='\xd' && a!='\xa'){
		s+=a;
		fh.Read(&a,1);
		if(fh.Eof())
			break;
	}
	return s;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:13,代码来源:Unit3DLoader.cpp

示例8: GetLine

static std::string GetLine(CFileHandler& fh)
{
	std::string s = "";
	char a;
	fh.Read(&a, 1);
	while (a!='\n' && a!='\r') {
		s += a;
		fh.Read(&a, 1);
		if (fh.Eof())
			break;
	}
	return s;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:13,代码来源:GuiKeyReader.cpp

示例9: GetLine

// returns next line (without newlines)
static string GetLine(CFileHandler& fh)
{
	lineNumber++;
	char a;
	string s = "";
	while (true) {
		a = fh.Peek();
		if (a == EOF)  { break; }
		fh.Read(&a, 1);
		if (a == '\n') { break; }
		if (a != '\r') { s += a; }
	}
	return s;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:15,代码来源:KeyBindings.cpp

示例10: GetCleanLine

// returns next non-blank line (without newlines or comments)
static string GetCleanLine(CFileHandler& fh)
{
	string::size_type pos;
	while (true) {
		if (fh.Eof()) {
			return ""; // end of file
		}
		string line = GetLine(fh);

		pos = line.find_first_not_of(" \t");
		if (pos == string::npos) {
			continue; // blank line
		}

		pos = line.find("//");
		if (pos != string::npos) {
			line.erase(pos);
			pos = line.find_first_not_of(" \t");
			if (pos == string::npos) {
				continue; // blank line (after removing comments)
			}
		}

		return line;
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:27,代码来源:KeyBindings.cpp

示例11: ReadMapTileFileHeader

/// Read TileFileHeader head from file src
void CSMFMapFile::ReadMapTileFileHeader(TileFileHeader& head, CFileHandler& file)
{
	file.Read(&head.magic,sizeof(head.magic));
	head.version = ReadInt(file);
	head.numTiles = ReadInt(file);
	head.tileSize = ReadInt(file);
	head.compressionType = ReadInt(file);
}
开发者ID:sprunk,项目名称:spring,代码行数:9,代码来源:SMFMapFile.cpp

示例12: VorbisStreamSeek

	int VorbisStreamSeek(void* datasource, ogg_int64_t offset, int whence)
	{
		CFileHandler* buffer = static_cast<CFileHandler*>(datasource);
		if (whence == SEEK_SET)
		{
			buffer->Seek(offset, std::ios_base::beg);
		}
		else if (whence == SEEK_CUR)
		{
			buffer->Seek(offset, std::ios_base::cur);
		}
		else if (whence == SEEK_END)
		{
			buffer->Seek(offset, std::ios_base::end);
		}

		return 0;
	}
开发者ID:FriedRice,项目名称:spring,代码行数:18,代码来源:OggStream.cpp

示例13: Init

void CTAPalette::Init(CFileHandler& paletteFile)
{
	for (unsigned c = 0; c < NUM_PALETTE_ENTRIES; ++c) {
		for (unsigned c2 = 0; c2 < 4; ++c2) {
			paletteFile.Read(&p[c][c2], 1);
		}
		p[c][3] = 255;
	}
}
开发者ID:Arkazon,项目名称:spring,代码行数:9,代码来源:TAPalette.cpp

示例14: LoadToken

std::string CSpawnScript::LoadToken(CFileHandler& file)
{
	std::string s;
	char c;

	while (!file.Eof()) {
		file.Read(&c,1);
		if(c>='0' && c<='z')
			break;
	}
	s += c;
	while (!file.Eof()) {
		file.Read(&c,1);
		if(c<'0' || c>'z')
			return s;
		s+=c;
	}
	return s;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:19,代码来源:SpawnScript.cpp

示例15: CFileHandler

void CPreGame::LoadMap(const std::string& mapName, const bool forceReload)
{
	static bool alreadyLoaded = false;

	if (!alreadyLoaded || forceReload)
	{
		CFileHandler* f = new CFileHandler("maps/" + mapName);
		if (!f->FileExists()) {
			vector<string> ars = archiveScanner->GetArchivesForMap(mapName);
			if (ars.empty()) {
				throw content_error("Couldn't find any archives for map '" + mapName + "'.");
			}
			for (vector<string>::iterator i = ars.begin(); i != ars.end(); ++i) {
				if (!vfsHandler->AddArchive(*i, false)) {
					throw content_error("Couldn't load archive '" + *i + "' for map '" + mapName + "'.");
				}
			}
		}
		delete f;
		alreadyLoaded = true;
	}
}
开发者ID:Dmytry,项目名称:spring,代码行数:22,代码来源:PreGame.cpp


注:本文中的CFileHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。