本文整理汇总了C++中CDirectory类的典型用法代码示例。如果您正苦于以下问题:C++ CDirectory类的具体用法?C++ CDirectory怎么用?C++ CDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Split_Full_Path
bool CFSModule::Create_Directory( const std::string& Dir ) {
// Enforce leading /
if( Dir.empty() || (Dir.substr(0,1) != "/") || (Dir.substr(Dir.length() - 1) == "/") ) {
return NULL;
}
string Node;
string BaseDir;
// Split path into Node and Basedir
Split_Full_Path( Dir, BaseDir, Node );
CFSNode* pNode = Get_Node( BaseDir );
if( pNode->Get_Node_Type() != NODE_DIR ) {
return NULL;
}
CDirectory* pBaseDir = (CDirectory*)pNode;
// Create the directory
if( pBaseDir->Create_Directory( Node ) ) {
return true;
} else {
return false;
}
}
示例2: CDirectory
bool CDirectory::dir2fdd(char *sourceDirectory, char *fddImageName)
{
Debug::out(LOG_INFO, "CDirectory::dir2fdd() -- will try to create %s from %s", fddImageName, sourceDirectory);
CDirectory *pDir = new CDirectory();
pDir->DirectoryScan(sourceDirectory);
if(!pDir) {
Debug::out(LOG_ERROR, "CreateTreeFromDirectory failed...");
return false;
}
CFloppy floppy;
floppy.Create(NB_HEAD,NB_SECTOR_PER_TRACK,NB_CYLINDER);
bool bOk = floppy.Fill( pDir, (char *) "CONF_FDD" );
if (bOk) {
Debug::out(LOG_INFO, "CDirectory::dir2fdd() -- Writing file %s", fddImageName);
floppy.WriteImage(fddImageName);
}
delete pDir;
return bOk;
}
示例3: szPath
bool CLanguage::Load ( const CString& szLangName )
{
CString szPath ( "../lang/%s/", szLangName.c_str () );
CDirectory dir ( szPath );
if ( !dir.IsOk ( ) )
return false;
for ( CDirectory::CIterator iter = dir.Begin ();
iter != dir.End ();
++iter )
{
CString szCur = iter.GetName ();
size_t iExt = szCur.rfind ( '.' );
if ( iExt != CString::npos )
{
if ( szCur.substr ( iExt ) == ".txt" )
{
LoadFile ( szLangName, szCur.substr ( 0, iExt ) );
}
}
}
m_bIsOk = true;
return true;
}
示例4: open
void CSingleIndexBarrelReader::open(const tchar* name)
{
m_name = name;
CDirectory* pDirectory = m_pIndex->getDirectory();
tstring s = m_name + _T(".fdi");
CIndexInput* pIndexInput = pDirectory->openInput(s.c_str());
m_pFieldsInfo->read(pIndexInput);
pIndexInput->close();
delete pIndexInput;
m_pStoredFieldsReader->open(pDirectory,name,m_pFieldsInfo);
m_pNormsReader->open(name,m_pFieldsInfo);
if(pDirectory->fileExists(m_name + _T(".del")))
{
CIndexInput* pDelInput = pDirectory->openInput(m_name + _T(".del"));
m_pDeletedDocs = new CBitVector(pDelInput);
delete pDelInput;
}
else m_pDeletedDocs = new CBitVector();
if(m_pTermReader)
{
delete m_pTermReader;
m_pTermReader = NULL;
}
if(m_pFieldsInfo->numIndexFields() > 1)
{
m_pTermReader = new CMultiFieldTermReader(pDirectory,name,m_pFieldsInfo,m_pDeletedDocs,getFactoryFinder());
m_pTermReader->setFilter(m_pDeletedDocs);
}
else if(m_pFieldsInfo->numIndexFields() == 1)
{
m_pFieldsInfo->startIterator();
CFieldInfo* pFieldInfo;
while (m_pFieldsInfo->hasNext())
{
pFieldInfo = m_pFieldsInfo->next();
if(pFieldInfo->isIndexed())
{
m_pTermReader = getFactoryFinder()->getFactory(pFieldInfo->getID())->createTermReader();
m_pTermReader->setFilter(m_pDeletedDocs);
m_pTermReader->open(pDirectory,name,pFieldInfo,m_pDeletedDocs);
break;
}
}
}
else
{
FIRTEX_THROW2(INDEX_COLLAPSE_ERROR,_T("the field number is 0."));
}
}
示例5: CDirectory
IDirectory *LibrarySystem::OpenDirectory(const char *path)
{
CDirectory *dir = new CDirectory(path);
if (!dir->IsValid())
{
delete dir;
return NULL;
}
return dir;
}
示例6: amx_open_dir
// native open_dir(dir[], firstfile[], length, &FileType:type = FileType_Unknown, bool:use_valve_fs=false, const valve_path_id[] = "GAME");
static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
{
int length;
const char* path = get_amxstring(amx, params[1], 0, length);
if (!*path)
{
return 0;
}
size_t numParams = *params / sizeof(cell);
if (numParams >= 4 && params[5] > 0)
{
const char* wildcardedPath = g_LibSys.PathFormat("%s%s*", path, (path[length - 1] != '/' && path[length - 1] != '\\') ? "/" : "");
const char* pathID = get_amxstring_null(amx, params[6], 1, length);
static FileFindHandle_t handle;
const char* pFirst = g_FileSystem->FindFirst(wildcardedPath, &handle, pathID);
if (!pFirst)
{
return 0;
}
set_amxstring_utf8(amx, params[2], pFirst, strlen(pFirst), params[3] + 1);
cell* fileType = get_amxaddr(amx, params[4]);
*fileType = g_FileSystem->FindIsDirectory(handle) ? FileType_Directory : FileType_File;
return reinterpret_cast<cell>(new DirectoryHandle(reinterpret_cast<void*>(&handle), true));
}
CDirectory* dir = g_LibSys.OpenDirectory(build_pathname("%s", path));
if (!dir)
{
return 0;
}
if (numParams >= 4)
{
cell* fileType = get_amxaddr(amx, params[4]);
*fileType = dir->IsEntryDirectory() ? FileType_Directory : FileType_File;
}
const char* entry = dir->GetEntryName();
set_amxstring_utf8(amx, params[2], entry, strlen(entry), params[3] + 1);
return reinterpret_cast<cell>(new DirectoryHandle(reinterpret_cast<void*>(dir), false));
}
示例7: GFRLOG_TRACE
bool vip_Start::Process()
{
GFRLOG_TRACE("VIP starts to process");
CDirectory dir;
list<string> filelist = dir.get_file_list(m_str_src);
list<string>::iterator it;
for (it = filelist.begin(); it != filelist.end(); ++it)
{
cout<< "Processing [" << *it << "]" <<endl;
this->load_file(*it);
}
return true;
}
示例8: Pop
CDirectory* CDirectoryQueue::Pop()
{
bool force_wait = false;
CDirectory* tmp;
CDirectory* tmpPrev;
EnterCriticalSection(&_cs);
tmpPrev = NULL;
tmp = _head;
while (tmp != NULL) {
if (tmp->TryLock()) {
if (tmp == _head)
_head = _head->_next;
if (tmpPrev != NULL)
tmpPrev->_next = tmp->_next; // unlink it
if (tmp == _tail)
_tail = tmpPrev;
--_length;
break;
}
Warning("Skipping locked directory %s (will return to it)",
tmp->GetDirectoryName());
tmpPrev = tmp;
tmp = tmp->_next;
}
if (tmp == NULL && _head != NULL) {
// There's at least one directory, but they're all in use by another
// copy of rl. Just grab the first one and wait on it.
tmp = _head;
_head = _head->_next;
if (tmp == _tail)
_tail = NULL;
--_length;
// wait until it's no longer in use..... However, don't wait inside the
// critical section.
force_wait = true;
}
ReleaseSemaphore(_hMaxWorkQueueSem, 1, NULL);
LeaveCriticalSection(&_cs);
if (tmp != NULL) // might be empty diff queue before masters are run
tmp->_next = NULL;
if (force_wait)
tmp->WaitLock();
return tmp;
}
示例9: strcpy
void CDirectory::DirectoryScan(const char *pDir)
{
char tmpName[_MAX_PATH];
strcpy(tmpName,pDir);
strcat(tmpName,"\\*.*");
DIR *dir = opendir((char *) pDir); // try to open the dir
if(dir == NULL) { // not found?
return;
}
while(1) { // while there are more files, store them
struct dirent *de = readdir(dir); // read the next directory entry
if(de == NULL) { // no more entries?
break;
}
if(de->d_type != DT_DIR && de->d_type != DT_REG) { // not a file, not a directory?
continue;
}
sprintf(tmpName,"%s/%s", pDir, de->d_name);
if(de->d_type == DT_DIR) { // for dir
if(de->d_name[0] == '.') { // skip . and ..
continue;
}
CDirectory *pNewDir = new CDirectory();
this->AddEntry(de, pNewDir, tmpName);
pNewDir->DirectoryScan(tmpName);
} else {
this->AddEntry(de, NULL, tmpName);
}
}
closedir(dir);
}
示例10: if
bool CFileOperations::FillFileItemList(const CVariant ¶meterObject, CFileItemList &list)
{
if (parameterObject.isMember("directory"))
{
CStdString media = parameterObject["media"].asString();
media = media.ToLower();
CStdString strPath = parameterObject["directory"].asString();
if (!strPath.empty())
{
CFileItemList items;
CStdString extensions = "";
CStdStringArray regexps;
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_settings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_settings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_settings.m_pictureExtensions;
}
CDirectory directory;
if (directory.GetDirectory(strPath, items, extensions))
{
items.Sort(SORT_METHOD_FILE, SortOrderAscending);
CFileItemList filteredDirectories;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
continue;
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else if ((media == "video" && items[i]->HasVideoInfoTag()) ||
(media == "music" && items[i]->HasMusicInfoTag()))
list.Add(items[i]);
else
{
CFileItem fileItem;
if (FillFileItem(items[i], fileItem, media))
list.Add(CFileItemPtr(new CFileItem(fileItem)));
else if (media == "files")
list.Add(items[i]);
}
}
if (parameterObject.isMember("recursive") && parameterObject["recursive"].isBoolean())
{
for (int i = 0; i < filteredDirectories.Size(); i++)
{
CVariant val = parameterObject;
val["directory"] = filteredDirectories[i]->GetPath();
FillFileItemList(val, list);
}
}
return true;
}
}
}
return false;
}
示例11: amx_get_dir
// native next_file(dirh, buffer[], length, &FileType:type = FileType_Unknown);
static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
{
DirectoryHandle* p = reinterpret_cast<DirectoryHandle*>(params[1]);
if (!p)
{
return 0;
}
size_t numParams = *params / sizeof(cell);
if (p->valvefs)
{
FileFindHandle_t* handle = reinterpret_cast<FileFindHandle_t*>(p->handle);
if (!handle)
{
return 0;
}
const char* entry = g_FileSystem->FindNext(*handle);
if (!entry)
{
return 0;
}
if (numParams >= 4)
{
cell* fileType = get_amxaddr(amx, params[4]);
*fileType = g_FileSystem->FindIsDirectory(*handle) ? FileType_Directory : FileType_File;
}
set_amxstring_utf8(amx, params[2], entry, strlen(entry), params[3] + 1);
}
else
{
CDirectory* handle = reinterpret_cast<CDirectory*>(p->handle);
if (!handle)
{
return 0;
}
handle->NextEntry();
if (!handle->MoreFiles())
{
return 0;
}
if (numParams >= 4)
{
cell* fileType = get_amxaddr(amx, params[4]);
*fileType = handle->IsEntryDirectory() ? FileType_Directory : FileType_File;
}
const char* entry = handle->GetEntryName();
set_amxstring_utf8(amx, params[2], entry, strlen(entry), params[3] + 1);
}
return 1;
}
示例12: PopulateTrainersList
void CGUIWindowPrograms::PopulateTrainersList()
{
CDirectory directory;
CFileItemList trainers;
CFileItemList archives;
CFileItemList inArchives;
// first, remove any dead items
std::vector<CStdString> vecTrainerPath;
m_database.GetAllTrainers(vecTrainerPath);
CGUIDialogProgress* m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
m_dlgProgress->SetLine(0,12023);
m_dlgProgress->SetLine(1,"");
m_dlgProgress->SetLine(2,"");
m_dlgProgress->StartModal();
m_dlgProgress->SetHeading(12012);
m_dlgProgress->ShowProgressBar(true);
m_dlgProgress->Progress();
bool bBreak=false;
bool bDatabaseState = m_database.IsOpen();
if (!bDatabaseState)
m_database.Open();
m_database.BeginTransaction();
for (unsigned int i=0;i<vecTrainerPath.size();++i)
{
m_dlgProgress->SetPercentage((int)((float)i/(float)vecTrainerPath.size()*100.f));
CStdString strLine;
strLine.Format("%s %i / %i",g_localizeStrings.Get(12013).c_str(), i+1,vecTrainerPath.size());
m_dlgProgress->SetLine(1,strLine);
m_dlgProgress->Progress();
if (!CFile::Exists(vecTrainerPath[i]) || vecTrainerPath[i].find(g_guiSettings.GetString("myprograms.trainerpath",false)) == -1)
m_database.RemoveTrainer(vecTrainerPath[i]);
if (m_dlgProgress->IsCanceled())
{
bBreak = true;
m_database.RollbackTransaction();
break;
}
}
if (!bBreak)
{
CLog::Log(LOGDEBUG,"trainerpath %s",g_guiSettings.GetString("myprograms.trainerpath",false).c_str());
directory.GetDirectory(g_guiSettings.GetString("myprograms.trainerpath").c_str(),trainers,".xbtf|.etm");
if (g_guiSettings.GetString("myprograms.trainerpath",false).IsEmpty())
{
m_database.RollbackTransaction();
m_dlgProgress->Close();
return;
}
directory.GetDirectory(g_guiSettings.GetString("myprograms.trainerpath").c_str(),archives,".rar|.zip",false); // TODO: ZIP SUPPORT
for( int i=0;i<archives.Size();++i)
{
if (stricmp(URIUtils::GetExtension(archives[i]->GetPath()),".rar") == 0)
{
g_RarManager.GetFilesInRar(inArchives,archives[i]->GetPath(),false);
CHDDirectory dir;
dir.SetMask(".xbtf|.etm");
for (int j=0;j<inArchives.Size();++j)
if (dir.IsAllowed(inArchives[j]->GetPath()))
{
CFileItemPtr item(new CFileItem(*inArchives[j]));
CStdString strPathInArchive = item->GetPath();
CStdString path;
URIUtils::CreateArchivePath(path, "rar", archives[i]->GetPath(), strPathInArchive,"");
item->SetPath(path);
trainers.Add(item);
}
}
if (stricmp(URIUtils::GetExtension(archives[i]->GetPath()),".zip")==0)
{
// add trainers in zip
CStdString strZipPath;
URIUtils::CreateArchivePath(strZipPath,"zip",archives[i]->GetPath(),"");
CFileItemList zipTrainers;
directory.GetDirectory(strZipPath,zipTrainers,".etm|.xbtf");
for (int j=0;j<zipTrainers.Size();++j)
{
CFileItemPtr item(new CFileItem(*zipTrainers[j]));
trainers.Add(item);
}
}
}
if (!m_dlgProgress)
m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
m_dlgProgress->SetPercentage(0);
m_dlgProgress->ShowProgressBar(true);
CLog::Log(LOGDEBUG,"# trainers %i",trainers.Size());
m_dlgProgress->SetLine(1,"");
int j=0;
while (j < trainers.Size())
{
if (trainers[j]->m_bIsFolder)
trainers.Remove(j);
else
j++;
}
for (int i=0;i<trainers.Size();++i)
//.........这里部分代码省略.........
示例13: GetDirectory
JSON_STATUS CFileOperations::GetDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const Value ¶meterObject, Value &result)
{
CStdString media = parameterObject["media"].asString();
media = media.ToLower();
CDirectory directory;
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
CStdStringArray regexps;
CStdString extensions = "";
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_stSettings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_stSettings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_stSettings.m_pictureExtensions;
}
if (directory.GetDirectory(strPath, items, extensions))
{
CFileItemList filteredDirectories, filteredFiles;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->m_strPath, regexps))
continue;
if (items[i]->IsSmb())
{
CURI url(items[i]->m_strPath);
items[i]->m_strPath = url.GetWithoutUserDetails();
}
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else
filteredFiles.Add(items[i]);
}
// Check if the "fields" list exists
// and make sure it contains the "file"
// field
Value param = parameterObject;
if (!param.isMember("fields"))
param["fields"] = Value(arrayValue);
bool hasFileField = false;
for (unsigned int i = 0; i < param["fields"].size(); i++)
{
if (param["fields"][i].asString().compare("file") == 0)
{
hasFileField = true;
break;
}
}
if (!hasFileField)
param["fields"].append("file");
HandleFileItemList(NULL, true, "files", filteredDirectories, param, result);
for (unsigned int index = 0; index < result["files"].size(); index++)
{
result["files"][index]["filetype"] = "directory";
}
int count = result["limits"]["total"].asInt();
HandleFileItemList(NULL, true, "files", filteredFiles, param, result);
for (unsigned int index = count; index < result["files"].size(); index++)
{
result["files"][index]["filetype"] = "file";
}
count += result["limits"]["total"].asInt();
result["limits"]["end"] = count;
result["limits"]["total"] = count;
result["success"] = true;
return OK;
}
return InvalidParams;
}
示例14: FillFileItemList
bool CFileOperations::FillFileItemList(const Value ¶meterObject, CFileItemList &list)
{
if (parameterObject.isObject() && parameterObject.isMember("directory"))
{
CStdString media = "files";
if (parameterObject.isMember("media"))
{
if (parameterObject["media"].isString())
media = parameterObject["media"].asString();
else
return false;
}
media = media.ToLower();
if (media.Equals("video") || media.Equals("music") || media.Equals("pictures") || media.Equals("files") || media.Equals("programs"))
{
CDirectory directory;
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
CStdStringArray regexps;
CStdString extensions = "";
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_stSettings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_stSettings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_stSettings.m_pictureExtensions;
}
if (directory.GetDirectory(strPath, items, extensions))
{
CFileItemList filteredDirectories;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->m_strPath, regexps))
continue;
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else
list.Add(items[i]);
}
if (parameterObject.isMember("recursive") && parameterObject["recursive"].isBool())
{
for (int i = 0; i < filteredDirectories.Size(); i++)
{
Value val = parameterObject;
val["directory"] = filteredDirectories[i]->m_strPath;
FillFileItemList(val, list);
}
}
return true;
}
}
}
return false;
}
示例15: get_localinfo
bool CGameConfig::Reparse(char *error, size_t maxlength)
{
m_Offsets.clear();
m_OffsetsByClass.clear();
m_Keys.clear();
m_Addresses.clear();
char path[PLATFORM_MAX_PATH];
const char *dataDir = get_localinfo("amxx_datadir", "addons/amxmodx/data");
build_pathname_r(path, sizeof(path), "%s/gamedata/%s/master.games.txt", dataDir, m_File);
if (!g_LibSys.PathExists(path))
{
// Single config file without master
g_LibSys.PathFormat(path, sizeof(path), "%s.txt", m_File);
if (!EnterFile(path, error, maxlength))
{
return false;
}
// Allow customizations of default gamedata files
build_pathname_r(path, sizeof(path), "%s/gamedata/custom/%s.txt", dataDir, m_File);
if (g_LibSys.PathExists(path))
{
g_LibSys.PathFormat(path, sizeof(path), "custom/%s.txt", m_File);
auto success = EnterFile(path, error, maxlength);
if (success)
{
AMXXLOG_Log("[AMXX] Parsed custom gamedata override file: %s", path);
}
return success;
}
return true;
}
SMCError err;
SMCStates state = { 0, 0 };
ke::Vector<ke::AString> fileList;
MasterReader.m_FileList = &fileList;
err = textparsers->ParseSMCFile(path, &MasterReader, &state, error, maxlength);
if (err != SMCError_Okay)
{
const char *msg = textparsers->GetSMCErrorString(err);
AMXXLOG_Error("Error parsing master gameconf file \"%s\":", path);
AMXXLOG_Error("Error %d on line %d, col %d: %s", err, state.line, state.col, msg ? msg : "Unknown error");
return false;
}
for (size_t i = 0; i < fileList.length(); ++i)
{
g_LibSys.PathFormat(path, sizeof(path), "%s/%s", m_File, fileList[i].chars());
if (!EnterFile(path, error, maxlength))
{
return false;
}
}
build_pathname_r(path, sizeof(path), "%s/gamedata/%s/custom", dataDir, m_File);
CDirectory *customDir = g_LibSys.OpenDirectory(path);
if (!customDir)
{
return true;
}
while (customDir->MoreFiles())
{
if (!customDir->IsEntryFile())
{
customDir->NextEntry();
continue;
}
const char *currentFile = customDir->GetEntryName();
size_t length = strlen(currentFile);
if (length > 4 && strcmp(¤tFile[length - 4], ".txt") != 0)
{
customDir->NextEntry();
continue;
}
g_LibSys.PathFormat(path, sizeof(path), "%s/custom/%s", m_File, currentFile);
if (!EnterFile(path, error, maxlength))
{
g_LibSys.CloseDirectory(customDir);
//.........这里部分代码省略.........