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


C++ FileStream::Remains方法代码示例

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


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

示例1: AddCacheFile

DataStream* ResourceManager::AddCacheFile(const char *filename)
{
	if (!core->GameOnCD)
		return FileStream::OpenFile(filename);

	char fname[_MAX_PATH];
	ExtractFileFromPath(fname, filename);

	FileStream *dest = OpenCacheFile(fname);

	// already in cache
	if (dest)
		return dest;

	FileStream* src = FileStream::OpenFile(fname);
	dest = CreateCacheFile(fname);

	if (!src || !dest) {
		printMessage("ResourceManager", "Failed to copy file '%s'\n", RED, fname);
		abort();
	}

	size_t blockSize = 1024 * 1000;
	char buff[1024 * 1000];
	do {
		if (blockSize > src->Remains())
			blockSize = src->Remains();
		size_t len = src->Read(buff, blockSize);
		size_t c = dest->Write(buff, len);
		if (c != len) {
			printMessage("ResourceManager", "Failed to write to file '%s'\n", RED, fname);
			abort();
		}
	} while (src->Remains());

	delete src;
	delete dest;

	return OpenCacheFile(fname);
}
开发者ID:,项目名称:,代码行数:40,代码来源:

示例2: InitializeKeyMap

bool KeyMap::InitializeKeyMap(const char *inifile, const char *tablefile)
{
	AutoTable kmtable(tablefile);

	if (!kmtable) {
		return false;
	}

	char tINIkeymap[_MAX_PATH];
	PathJoin( tINIkeymap, core->GamePath, inifile, NULL );
	FileStream* config = FileStream::OpenFile( tINIkeymap );

	if (config == NULL) {
		Log(WARNING, "KeyMap", "There is no '%s' file...", inifile);
		return false;
	}
	char name[KEYLENGTH+1], value[_MAX_PATH + 3];
	while (config->Remains()) {
		char line[_MAX_PATH];

		if (config->ReadLine(line, _MAX_PATH) == -1)
			break;

		if ((line[0] == '#') ||
			( line[0] == '[' ) ||
			( line[0] == '\r' ) ||
			( line[0] == '\n' ) ||
			( line[0] == ';' )) {
			continue;
		}

		name[0] = 0;
		value[0] = 0;

		//ignore possible space after the =, sadly we cannot do the same with
		//spaces before it
		if (sscanf( line, "%[^=]= %[^\r\n]", name, value )!=2)
			continue;

		strnlwrcpy(name,name,KEYLENGTH);
		//remove trailing spaces (bg1 ini file contains them)
		char *nameend = name + strlen( name ) - 1;
		while (nameend >= name && strchr( " \t\r\n", *nameend )) {
			*nameend-- = '\0';
		}

		//change internal spaces to underscore
		for(int c=0;c<KEYLENGTH;c++) if (name[c]==' ') name[c]='_';

		int l = strlen(value);
		Function *fun;
		void *tmp;

		if (l<0 || l>1 || keymap.Lookup(value, tmp) ) {
			print("Ignoring key %s", value);
			continue;
		}

		const char *module;
		const char *function;
		const char *group;

		if (kmtable->GetRowIndex(name)>=0 ) {
			module = kmtable->QueryField(name, "MODULE");
			function = kmtable->QueryField(name, "FUNCTION");
			group = kmtable->QueryField(name, "GROUP");
		} else {
			module = kmtable->QueryField("Default","MODULE");
			function = kmtable->QueryField("Default","FUNCTION");
			group = kmtable->QueryField("Default","GROUP");
			print("Adding key %s with function %s::%s", value, module, function);
		}
		fun = new Function(module, function, atoi(group));
		keymap.SetAt(value, fun);
	}
	delete config;
	return true;
}
开发者ID:BehoIder,项目名称:gemrb,代码行数:78,代码来源:KeyMap.cpp


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