本文整理汇总了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);
}
示例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;
}