本文整理汇总了C++中Directory类的典型用法代码示例。如果您正苦于以下问题:C++ Directory类的具体用法?C++ Directory怎么用?C++ Directory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Directory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lsRl
int Directory::lsRl(File *obje)
{
Directory* d = dynamic_cast<Directory*>(obje);
if(d != NULL)
{
cout << endl;
cout << "." << d->getPathName() << ":" << endl;
for (int i = 0; i < d->v.size(); i++)
{
Directory* di = dynamic_cast<Directory*>(d->v[i]);
if(di != NULL)
{
cout << "drwxr-xr-x " << d->v[i]->getName() << " " << d->v[i]->getOwner() << " "
<< d->v[i]->getSize() << " " << d->v[i]->getLastModificaiton() << endl;
}
Executable* e = dynamic_cast<Executable*>(d->v[i]);
if(e != NULL)
{
cout << "-rwxrwxr-x " << d->v[i]->getName() << " " << d->v[i]->getOwner() << " "
<< d->v[i]->getSize() << " " << d->v[i]->getLastModificaiton() << endl;
}
TextFile* t = dynamic_cast<TextFile*>(d->v[i]);
if(t != NULL)
{
cout << "-rw-rw-r--" << d->v[i]->getName() << " " << d->v[i]->getOwner() << " "
<< d->v[i]->getSize() << " " << d->v[i]->getLastModificaiton() << endl;
}
}
for (int i = 0; i < d->v.size(); i++)
{
Directory* d2 = dynamic_cast<Directory*>(d->v[i]);
if(d2 != NULL)
lsRl(d2);
else
return 0;
}
}
}
示例2: dir
/**
* Process orphaned index files, those that exist but do not have a
* corresponding history file.
*
* Process all .idx files looking for the corresponding HistoryFile in
* the history file map.
*/
void
aviary::history::processOrphanedIndices()
{
const char *file = NULL;
Directory dir ( m_path.Value() );
dir.Rewind();
while ( ( file = dir.Next() ) )
{
// Skip all non-history index files, e.g. history and history.*
if ( strncmp ( file, "history.", 8 ) ||
strncmp ( file + ( strlen ( file ) - 4 ), HISTORY_INDEX_SUFFIX, 4 ) ) continue;
// XXX: This is ugly because it indicates we know details
// of how HistoryFile implements index files.
// The index file is "history.%ld.idx" where %ld is the id
// of the history file the index is for.
long unsigned int id;
int count = sscanf ( file, "history.%ld.idx", &id );
if ( 1 != count )
{
dprintf ( D_ALWAYS, "Error parsing %s, skipping.\n", file );
continue;
}
HistoryFileListType::iterator entry = m_historyFiles.find ( id );
if ( m_historyFiles.end() == entry )
{
// The index is dangling, remove it.
if ( !dir.Remove_Current_File() )
{
dprintf ( D_ALWAYS, "Failed to remove: %s\n", file );
}
}
}
}
示例3: packagesNodeReleaser
int
BootVolume::_OpenSystemPackage()
{
// open the packages directory
Node* packagesNode = fSystemDirectory->Lookup("packages", false);
if (packagesNode == NULL)
return -1;
MethodDeleter<Node, status_t> packagesNodeReleaser(packagesNode,
&Node::Release);
if (!S_ISDIR(packagesNode->Type()))
return -1;
Directory* packageDirectory = (Directory*)packagesNode;
// search for the system package
int fd = -1;
void* cookie;
if (packageDirectory->Open(&cookie, O_RDONLY) == B_OK) {
char name[B_FILE_NAME_LENGTH];
while (packageDirectory->GetNextEntry(cookie, name, sizeof(name))
== B_OK) {
// The name must end with ".hpkg".
size_t nameLength = strlen(name);
if (nameLength < 6 || strcmp(name + nameLength - 5, ".hpkg") != 0)
continue;
// The name must either be "haiku.hpkg" or start with "haiku-".
if (strcmp(name, "haiku.hpkg") == 0
|| strncmp(name, "haiku-", 6) == 0) {
fd = open_from(packageDirectory, name, O_RDONLY);
break;
}
}
packageDirectory->Close(cookie);
}
return fd;
}
示例4: GetSongIDForFile
int SongDatabase::GetSongIDForFile(Directory File, VSRG::Song* In)
{
int ret;
int Out = -1;
SC(sqlite3_bind_text(st_GetSIDFromFilename, 1, File.c_path(), File.path().length(), SQLITE_STATIC));
int r = sqlite3_step(st_GetSIDFromFilename);
if (r == SQLITE_ROW)
{
// We found a song with ID and everything..
Out = sqlite3_column_int(st_GetSIDFromFilename, 0);
}
else
{
assert(In); // Okay, this is a query isn't it? Why doesn't the song exist?
// Okay then, insert the song.
// So now the latest entry is what we're going to insert difficulties and files into.
SC(sqlite3_bind_text(st_SngInsertQuery, 1, In->SongName.c_str(), In->SongName.length(), SQLITE_STATIC));
SC(sqlite3_bind_text(st_SngInsertQuery, 2, In->SongAuthor.c_str(), In->SongAuthor.length(), SQLITE_STATIC));
SC(sqlite3_bind_text(st_SngInsertQuery, 3, In->Subtitle.c_str(), In->Subtitle.length(), SQLITE_STATIC));
SC(sqlite3_bind_text(st_SngInsertQuery, 4, In->SongFilename.c_str(), In->SongFilename.length(), SQLITE_STATIC));
SC(sqlite3_bind_text(st_SngInsertQuery, 5, In->BackgroundFilename.c_str(), In->BackgroundFilename.length(), SQLITE_STATIC));
SC(sqlite3_bind_int(st_SngInsertQuery, 6, In->Mode));
SC(sqlite3_bind_text(st_SngInsertQuery, 7, In->SongPreviewSource.c_str(), In->SongPreviewSource.length(), SQLITE_STATIC));
SC(sqlite3_bind_double(st_SngInsertQuery, 8, In->PreviewTime));
SCS(sqlite3_step(st_SngInsertQuery));
SC(sqlite3_reset(st_SngInsertQuery));
sqlite3_step(st_GetLastSongID);
Out = sqlite3_column_int(st_GetLastSongID, 0);
sqlite3_reset(st_GetLastSongID);
}
sqlite3_reset(st_GetSIDFromFilename);
if (In) In->ID = Out;
return Out;
}
示例5: AppDebugOut
void Directory::DebugPrint ( int indent ) const
{
//
// Print our name
for ( int t = 0; t < indent; ++t )
{
AppDebugOut( " " );
}
AppDebugOut ( "+===" );
AppDebugOut ( "%s\n", m_name );
//
// Print our data
for ( int j = 0; j < m_data.Size(); ++j )
{
if ( m_data.ValidIndex(j) )
{
DirectoryData *data = m_data[j];
AppAssert( data );
data->DebugPrint( indent + 1 );
}
}
//
// Recurse into subdirs
for ( int i = 0; i < m_subDirectories.Size(); ++i )
{
if ( m_subDirectories.ValidIndex(i) )
{
Directory *subDir = m_subDirectories[i];
AppAssert( subDir );
subDir->DebugPrint( indent + 1 );
}
}
}
示例6: while
/**
* \brief Rescan directories
*/
void Scanner::rescanDirs()
{
Directory *dir;
std::string path;
while (scanCount() > 0) {
/* Get directory instance from path */
path = Directory::correctDirName(getNextScan());
if (path.empty()) {
continue;
}
dir = dirFromPath(path);
if (!dir) {
/* Directory not found in our tree */
MSG_WARNING(msg_module, "Cannot rescan %s, it's not part of this tree of it's too deep", path.c_str());
continue;
}
/* rescan directory */
dir->rescan();
}
}
示例7: getDirectoryContent
/*
* Решава пътя и извиква printContent() na namerenata директория
*/
void CommandPrompt::getDirectoryContent(string path){
if (path.size() == 0) {
currentDir->printContent();
return;
}
if (path.find_first_of('/') == string::npos) {
Directory* temp;
temp = currentDir->findDirByName(path);
if (temp == NULL || temp->isType(NULL_FILE)) {
cerr << "Directory not found!" << endl;
return;
}
temp->printContent();
}
else {
Directory* temp;
temp = fs.getDir(path);
if (temp != NULL)
temp->printContent();
else
cerr << "Directory not found!" << endl;
}
}
示例8: language_name
vector<string> i18n::LanguagesAvailable(void)
{
vector<string> list;
Directory dir;
dir.OpenDir("data/i18n");
{
const Directory::Entries& files = dir.GetEntries();
for_each(files.begin(), files.end(), [&list](const Dirent& file)
{
if (file.d_type == DT_REG)
{
string language_name(file.d_name);
language_name = language_name.substr(0, language_name.size() - 5); // where 5 is '.json'
list.push_back(language_name);
cout << "[i18n] Found language " << language_name << endl;
}
});
}
return (list);
}
示例9: Directory
void DisplayWidget::searchFile()
{
QString dirTree = git.getDataTree();
dirTree = dirTree.simplified();
QStringList listDir = dirTree.split(" ");
QMap<int, QString> map;
for (int i = 0, j = 0; i < listDir.size(); i++, j++)
map.insert(i, listDir.at(j));
// The Dialog is limited to listing files and subdirectories of the current directory,
// but the contents of subdirs can't be viewed.So it will be settled in a good way.
// Maybe replace QListWidget with QTreeWidget .
Directory *dir = new Directory(map, this);
if (dir->exec()){
QString fileName;
fileName = dir->selectedText();
QFileInfo fi(fileName);
fileName = fi.absoluteFilePath();
lineEdit->setText(fileName);
}
delete dir;
}
示例10: lsaR
int Directory::lsaR(File *obje)
{
Directory* d = dynamic_cast<Directory*>(obje);
if(d != NULL)
{
cout << endl;
cout << "." << d->getPathName() << ":" << endl;
cout << ". .. ";
for (int i = 0; i < d->v.size(); i++)
{
cout << d->v[i]->getName() << " ";
}
cout << endl;
for (int i = 0; i < d->v.size(); i++)
{
Directory* d2 = dynamic_cast<Directory*>(d->v[i]);
if(d2 != NULL)
lsaR(d2);
else
return 0;
}
}
}
示例11: exitTraversal
bool DirectoryTree::TraverseDepthFirst(Directory& dir, const DirectoryEntryVisitor& visitor, bool postOrder)
{
if (!dir)
{
return true;
}
bool exitTraversal(false);
DirectoryEntry entry;
while ((entry = dir.Next()) && !exitTraversal)
{
if(!postOrder)
{
if(!visitor(this, entry))
{
return false;
}
}
if (entry.fileType == FileType::Directory)
{
auto subDir = dir.Descend(entry);
exitTraversal = !TraverseDepthFirst(*subDir, visitor, postOrder);
}
if (postOrder)
{
if (!visitor(this, entry))
{
return false;
}
}
}
return !exitTraversal;
}
示例12: Dir_Read
void DirectoryManager::openAllDir(char * path)
{
FileSystem& fs = *FileSystem::getInstance();
TableManager& tm = *TableManager::getInstance();
PathManager& pm = *PathManager::getInstance();
vector<string> vStr = *pm.getAllAbsPath(path);
vector<string> vAllDirec = pm.doAnalyzeFolder(path);
Directory dir = *returnDir(0); // root의 dir 객체 가져오기
int fd = tm.fileOpenEvent(0, fs.inodeBlock->getInodeData(0));
openedDir_FDList.push_back(fd);
for (int i = 1; i < vStr.size(); i++)
{
// 상위 디렉토리를 통해 먼저 inodeNum과 Block을 얻는다.
Entry* en = dir.findName(stringToCharArr(vAllDirec[i]));
if (!en) {
cout << "Name : " << vAllDirec[i] << endl;
throw "dir의 엔트리에서 name을 찾지 못함.";
}
int inodeNum = en->inodeNum;
Inode inodeBl = fs.inodeBlock->getInodeData(inodeNum);
dir = Dir_Read(stringToCharArr(vStr[i]));
if (tm.isExistInInodeTable(inodeNum))
{
cout << endl << "open되어있는 디렉토리임" << endl;
throw "error in DirectoryManager.cpp in allOpen Func";// fd = 0 -> 이미 오픈되어있는 경우
}
fd = tm.fileOpenEvent(inodeNum, inodeBl);
openedDir_FDList.push_back(fd);
openedDirList.push_back(dir);
}
}
示例13: checkIndex
int
checkIndex(Disk &disk,char *attribute,block_run &run,bool collect)
{
Directory *index = (Directory *)Inode::Factory(&disk,run);
status_t status;
if (index == NULL || (status = index->InitCheck()) < B_OK)
{
fprintf(stderr," Could not get index directory for \"%s\": %s!\n",attribute,index ? strerror(status) : "not found/corrupted");
return -1;
}
printf("\nCheck \"%s\" index's on-disk structure...\n",attribute);
//dump_inode(index->InodeBuffer());
BPlusTree *tree;
if (index->GetTree(&tree) < B_OK || tree->Validate(true) < B_OK)
{
fprintf(stderr," B+Tree of index \"%s\" seems to be corrupt!\n",attribute);
//return -1;
}
if (collect && (!gDoNotCheckIndex || !gDoNotCheckForFiles))
collectFiles(disk);
if (!gDoNotCheckIndex)
{
printf("Check for non-existing files in index \"%s\"...\n",attribute);
checkIndexForNonExistingFiles(disk,*tree);
}
if (!gDoNotCheckForFiles)
{
printf("Check for files not in index \"%s\" (this may take even more time)...\n",attribute);
checkFiles(disk,*tree,attribute);
}
return 0;
}
示例14: DirectoryEntry
inline void CachePolicy::registerCacheAccess( Directory& dir, uint64_t tag, size_t size, bool input, bool output )
{
bool didCopyIn = false;
CacheEntry *ce;
ce = _cache.getEntry( tag );
unsigned int version=0;
if ( ce != NULL ) version = ce->getVersion()+1;
DirectoryEntry *de = dir.getEntry( tag, version );
if ( de == NULL ) { // Memory access not registered in the directory
bool inserted;
DirectoryEntry d = DirectoryEntry( tag, 0, ( output ? &_cache : NULL ), dir.getCacheMapSize() );
de = &(dir.insert( tag, d, inserted ));
if (!inserted) {
if ( output ) {
de->setOwner(&_cache);
de->setInvalidated(false);
ce->setFlushTo( &dir );
}
}
CacheEntry c = CacheEntry( NULL, size, tag, 0, output, input );
ce = &(_cache.insert( tag, c, inserted ));
if (inserted) { // allocate it
ce->setAddress( _cache.allocate( dir, size , tag) );
ce->setAllocSize( size );
if (input) {
CopyDescriptor cd = CopyDescriptor(tag);
if ( _cache.copyDataToCache( cd, size ) ) {
ce->setCopying(false);
}
}
} else { // wait for address
NANOS_INSTRUMENT( sys.getInstrumentation()->raiseOpenBurstEvent ( sys.getInstrumentation()->getInstrumentationDictionary()->getEventKey( "cache-wait" ), NANOS_CACHE_EVENT_REGISTER_CACHE_ACCESS_94 ); )
while ( ce->getAddress() == NULL ) {}
NANOS_INSTRUMENT( sys.getInstrumentation()->raiseCloseBurstEvent ( sys.getInstrumentation()->getInstrumentationDictionary()->getEventKey( "cache-wait" ), 0 ); )
}
示例15: ReadNextEntry
status_t ReadNextEntry(struct dirent* buffer, size_t size,
uint32& _countRead)
{
const char* name;
uint64 blockIndex;
int nextIterationState = OTHERS;
switch (iterationState) {
case DOT:
name = ".";
blockIndex = directory->BlockIndex();
nextIterationState = DOT_DOT;
break;
case DOT_DOT:
name = "..";
blockIndex = directory->ParentDirectory();
break;
default:
// TODO: Implement!
_countRead = 0;
return B_OK;
}
size_t entrySize = sizeof(dirent) + strlen(name);
if (entrySize > size)
return B_BUFFER_OVERFLOW;
buffer->d_dev = directory->GetVolume()->ID();
buffer->d_ino = blockIndex;
buffer->d_reclen = entrySize;
strcpy(buffer->d_name, name);
iterationState = nextIterationState;
_countRead = 1;
return B_OK;
}