本文整理汇总了C++中FileList::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ FileList::Clear方法的具体用法?C++ FileList::Clear怎么用?C++ FileList::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileList
的用法示例。
在下文中一共展示了FileList::Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlatformNormalize
// used for resolving case-insensative paths to case-sensative ones
// when appropriate IsCaseSensative() = true
bool PlatformNormalize(std::string &normpath, const std::string &path, const std::string root)
{
if (!FileList::IsCaseSensative()) // windows simply returns identity
{
// should only get hit on windows
if (root[root.length()-1] != '\\')
{
normpath = root + "\\" + path;
}
else
{
normpath = root + path;
}
return true;
}
// else it's a *nix system - normalize it to / instead of \ -
FileList curdir;
normpath = root;
// break path down into it's componants
std::vector<std::string> parts;
Expand(path, '/', parts);
bool found;
for (size_t i = 0; i < parts.size(); i++)
{
curdir.GetList(normpath);
found = false;
for (size_t j = 0; j < curdir.Size(); j++)
{
if (strLower(std::string(curdir[j])) ==
strLower(std::string(parts[i])))
{
normpath += std::string("/") + curdir[j];
found = true;
break;
}
}
if (!found)
return false; //yikes
curdir.Clear();
}
return true;
}
示例2: OnGetPatch
PluginReceiveResult AutopatcherServer::OnGetPatch(Packet *packet)
{
RakNet::BitStream inBitStream(packet->data, packet->length, false);
ThreadData threadData;
inBitStream.IgnoreBits(8);
inBitStream.Read(threadData.setId);
double lastUpdateDate;
inBitStream.Read(lastUpdateDate);
inBitStream.ReadCompressed(threadData.applicationName);
threadData.clientList=0;
// Check in-memory cache, use if possible rather than accessing database
if (threadData.applicationName==cache_appName && lastUpdateDate!=0 && cacheLoaded && cache_minTime!=0 && lastUpdateDate>cache_minTime)
{
threadData.systemAddress=packet->systemAddress;
threadData.server=this;
threadData.clientList=RakNet::OP_NEW<FileList>( _FILE_AND_LINE_ );
if (threadData.clientList->Deserialize(&inBitStream)==false)
{
RakNet::OP_DELETE(threadData.clientList, _FILE_AND_LINE_);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
if (threadData.clientList->fileList.Size()==0)
{
RakAssert(0);
RakNet::OP_DELETE(threadData.clientList, _FILE_AND_LINE_);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
char *userHash;
RakNet::RakString userFilename;
FileList patchList;
unsigned int i,j;
for (i=0; i < threadData.clientList->fileList.Size(); i++)
{
userHash=threadData.clientList->fileList[i].data;
userFilename=threadData.clientList->fileList[i].filename;
bool sentAnything=false;
// If the user file has a hash, check this hash against the hash stored with the patch, for the file of the same name
if (userHash)
{
if (threadData.clientList->fileList[i].dataLengthBytes!=HASH_LENGTH)
{
RakNet::OP_DELETE(threadData.clientList, _FILE_AND_LINE_);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
for (j=0; j < cache_patchedFiles.fileList.Size(); j++)
{
if (userFilename == cache_patchedFiles.fileList[j].filename)
{
if (memcmp(cache_patchedFiles.fileList[j].data, userHash, HASH_LENGTH)!=0)
{
// Full file will be sent below
}
else
{
// Send patch
RakAssert(cache_patchedFiles.fileList[j].context.op==PC_HASH_2_WITH_PATCH);
patchList.AddFile(userFilename,userFilename, 0, cache_patchedFiles.fileList[j].dataLengthBytes, cache_patchedFiles.fileList[j].fileLengthBytes, cache_patchedFiles.fileList[j].context, true, false);
sentAnything=true;
}
break;
}
}
}
if (sentAnything==false)
{
RakAssert(userFilename == cache_updatedFiles.fileList[j].filename);
patchList.AddFile(userFilename,userFilename, 0, cache_updatedFiles.fileList[j].dataLengthBytes, cache_updatedFiles.fileList[j].fileLengthBytes, cache_updatedFiles.fileList[j].context, true, false);
sentAnything=true;
break;
}
if (sentAnything==false)
{
// Failure to find file in cache
// Will fall to use database
patchList.Clear();
break;
}
}
if (patchList.fileList.Size()>0)
{
IncrementPatchingUserCount();
fileListTransfer->Send(&patchList, 0, packet->systemAddress, threadData.setId, priority, orderingChannel, this, 262144*4*4);
RakNet::BitStream bitStream1;
bitStream1.Write((unsigned char) ID_AUTOPATCHER_FINISHED_INTERNAL);
double t =(double) time(NULL);
bitStream1.Write(t);
SendUnified(&bitStream1, priority, RELIABLE_ORDERED, orderingChannel, packet->systemAddress, false);
//.........这里部分代码省略.........
示例3: UpdateApplicationFiles
//.........这里部分代码省略.........
if (addFile)
{
newFiles.AddFile(hardDriveFilename,hardDriveFilename, filesOnHarddrive.fileList[fileListIndex].data, filesOnHarddrive.fileList[fileListIndex].dataLengthBytes, filesOnHarddrive.fileList[fileListIndex].fileLengthBytes, FileListNodeContext(0,0), false);
}
}
// Go through query results that are marked as create
// If a file that is currently in the database is not on the harddrive, add it to the delete list
FileList deletedFiles;
for (unsigned i = 0; i != newestFiles.Size (); ++i)
{
const FileInfo & fi = newestFiles [i];
if (!fi.createFile)
continue; // If already false don't mark false again.
bool fileOnHarddrive=false;
for (unsigned fileListIndex=0; fileListIndex < filesOnHarddrive.fileList.Size(); fileListIndex++)
{
const char * hardDriveFilename=filesOnHarddrive.fileList[fileListIndex].filename;
//hardDriveHash=filesOnHarddrive.fileList[fileListIndex].data;
if (_stricmp(hardDriveFilename, fi.filename)==0)
{
fileOnHarddrive=true;
break;
}
}
if (!fileOnHarddrive)
deletedFiles.AddFile(fi.filename,fi.filename,0,0,0,FileListNodeContext(0,0), false);
}
// files on harddrive no longer needed. Free this memory since generating all the patches is memory intensive.
filesOnHarddrive.Clear();
// For each file in the delete list add a row indicating file deletion
for (unsigned fileListIndex=0; fileListIndex < deletedFiles.fileList.Size(); fileListIndex++)
{
if (fileListIndex%10==0)
printf("Tagging deleted files %i/%i\n", fileListIndex+1, deletedFiles.fileList.Size());
sprintf(query, "INSERT INTO FileVersionHistory(applicationID, filename, createFile, changeSetID, userName) VALUES (%i, '%s', FALSE,%i,'%s');",
applicationID, GetEscapedString(deletedFiles.fileList[fileListIndex].filename).C_String(), changeSetId, GetEscapedString(userName).C_String());
if (!ExecuteBlockingCommand (query))
{
Rollback();
deletedFiles.Clear();
newFiles.Clear();
return false;
}
}
// Clear the delete list as it is no longer needed.
deletedFiles.Clear();
// For each file in the create list
for (unsigned fileListIndex=0; fileListIndex < newFiles.fileList.Size(); fileListIndex++)
{
if (fileListIndex%10==0)
printf("Adding file %i/%i\n", fileListIndex+1, newFiles.fileList.Size());
const char * hardDriveFilename=newFiles.fileList[fileListIndex].filename;
const char * hardDriveData=newFiles.fileList[fileListIndex].data+HASH_LENGTH;
const char * hardDriveHash=newFiles.fileList[fileListIndex].data;
unsigned hardDriveDataLength=newFiles.fileList[fileListIndex].fileLengthBytes;
示例4: OnGetPatch
//.........这里部分代码省略.........
unsigned int i,j;
// FileList is the list of all files missing or changed as determined by the client
for (i=0; i < threadData.clientList->fileList.Size(); i++)
{
userHash=threadData.clientList->fileList[i].data;
userFilename=threadData.clientList->fileList[i].filename;
if (userHash)
{
// If the user has a hash, check for this file in cache_patchedFiles. If not found, or hash is wrong, use DB
if (threadData.clientList->fileList[i].dataLengthBytes!=HASH_LENGTH)
{
RakNet::OP_DELETE(threadData.clientList, _FILE_AND_LINE_);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
for (j=0; j < cache_patchedFiles.fileList.Size(); j++)
{
if (userFilename == cache_patchedFiles.fileList[j].filename)
{
if (memcmp(cache_patchedFiles.fileList[j].data, userHash, HASH_LENGTH)==0)
{
// Send patch
RakAssert(cache_patchedFiles.fileList[j].context.op==PC_HASH_2_WITH_PATCH);
patchList.AddFile(userFilename,userFilename, 0, cache_patchedFiles.fileList[j].dataLengthBytes, cache_patchedFiles.fileList[j].fileLengthBytes, cache_patchedFiles.fileList[j].context, true, false);
}
else
{
// Bad hash
cacheUpdateFailed=true;
}
break;
}
}
if (j==cache_patchedFiles.fileList.Size())
{
// Didn't find the patch even though the client has an older version of the file
cacheUpdateFailed=true;
}
}
else
{
// If the user does not have a hash, check for this file in cache_addedFiles. If not found, use DB
for (j=0; j < cache_addedFiles.fileList.Size(); j++)
{
if (userFilename == cache_addedFiles.fileList[j].filename)
{
// Send added file
patchList.AddFile(userFilename,userFilename, 0, cache_addedFiles.fileList[j].dataLengthBytes, cache_addedFiles.fileList[j].fileLengthBytes, cache_addedFiles.fileList[j].context, true, false);
break;
}
}
if (j==cache_addedFiles.fileList.Size())
{
// Didn't find the file in the cache even though the client asked for it
cacheUpdateFailed=true;
}
}
if (cacheUpdateFailed==true)
{
// Failure to find file in cache
// Will fall to use database
patchList.Clear();
break;
}
}
if (patchList.fileList.Size()>0)
{
if (IncrementPatchingUserCount(packet->systemAddress))
{
fileListTransfer->Send(&patchList, 0, packet->systemAddress, threadData.setId, priority, orderingChannel, this, 262144*4*4);
RakNet::BitStream bitStream1;
bitStream1.Write((unsigned char) ID_AUTOPATCHER_FINISHED_INTERNAL);
double t =(double) time(NULL);
bitStream1.Write(t);
SendUnified(&bitStream1, priority, RELIABLE_ORDERED, orderingChannel, packet->systemAddress, false);
RakNet::OP_DELETE(threadData.clientList, _FILE_AND_LINE_);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
}
}
RakNet::OP_DELETE(threadData.clientList, _FILE_AND_LINE_);
if (PatchingUserLimitReached())
{
AddToWaitingQueue(packet);
return RR_STOP_PROCESSING;
}
OnGetPatchInt(packet);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}