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;
         }
     }
 }
Exemplo n.º 2
0
/**
 * 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 );
            }
        }
    }
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
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 );        
        }
    }
}
Exemplo n.º 6
0
/**
 * \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();
	}
}
Exemplo n.º 7
0
/*
* Решава пътя и извиква 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;
	}
}
VOID CALLBACK TimerProc1(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
	vector<string> fileNames = dir.GetListFiles(dir_path, "*.*", false);
	vector<string> fileNames1 = dir.GetListFiles(dir_path1, "*.*", false);
	if(i<fileNames.size())
	{
		string fileName = fileNames[i];
		string fileName1=fileNames1[i];
		string fileFullName = dir_path + fileName;
		string fileFullName1=dir_path1+fileName1;
		_Global_Obj_Ptr->img1=imread(fileFullName);
		_Global_Obj_Ptr->img2=imread(fileFullName1);
		_Global_Obj_Ptr->OnBnClickedEnhance();	
		_Global_Obj_Ptr->OnBnClickedRegistry();
		_Global_Obj_Ptr->OnBnClickedLaplace();				
		i++;

	}
	else
	{
		i=0;
	}
}
VOID CALLBACK TimerProc14(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
	vector<string> fileNames = dir.GetListFiles(dir_path, "*.*", false);
	vector<string> fileNames1 = dir.GetListFiles(dir_path1, "*.*", false);
	if(i<fileNames.size())
	{
		string fileName = fileNames[i]; 
		string fileName1=fileNames1[i];
		string fileFullName = dir_path + fileName;
		string fileFullName1=dir_path1+fileName1;
		_Global_Obj_Ptr->img1=imread(fileFullName);
		_Global_Obj_Ptr->img2=imread(fileFullName1);		
		_Global_Obj_Ptr->OnBnClickedHisfusion();	
		string fileFullName2=dir_path2+fileName;
		imwrite(fileFullName2,_Global_Obj_Ptr->imgfusion);
		i++;

	}
	else
	{
		i=0;
	}
}
Exemplo n.º 10
0
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);
}
Exemplo n.º 11
0
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;
}
 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;
         }
     }
 }
Exemplo n.º 13
0
        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;
        }       
Exemplo n.º 14
0
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);
	}
}
Exemplo n.º 15
0
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;
}
Exemplo n.º 16
0
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 ); )
      }
Exemplo n.º 17
0
	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;
	}
Exemplo n.º 18
0
//-------- Begin of function GameFileArray::load_all_game_header --------//
//
// Load all headers of all saved game files in current directory.
//
void GameFileArray::load_all_game_header(const char *extStr)
{
	char full_path[MAX_PATH+1];
	int       i;
	Directory gameDir;
	GameFile  gameFile;
	File      file;

	if (!misc.path_cat(full_path, sys.dir_config, extStr, MAX_PATH))
	{
		ERR("Path to the config directory too long.\n");
		return;
	}
	gameDir.read(full_path, 1);  // 1-Sort file names

	//-------- read in the headers of all game sets -------//

	zap();

	for( i=1 ; i<=gameDir.size() ; i++ )
	{
		if (!misc.path_cat(full_path, sys.dir_config, gameDir[i]->name, MAX_PATH))
		{
			ERR("Path to the saved game too long.\n");
			continue;
		}
		if( file.file_open(full_path, 1, 1)      // last 1=allow varying read & write size
			&& file.file_read(&gameFile, sizeof(GameFile))
			&& gameFile.validate_header() )
		{
			strcpy( gameFile.file_name, gameDir[i]->name );  // in case that the name may be different
			gameFile.file_date = gameDir[i]->time;
	      linkin(&gameFile);
		}
		file.file_close();
	}
}
Exemplo n.º 19
0
Entry* File::findFile( char* filename,  int* dirInodeNo ) // ������ 
{
	FileSystem& fs = *FileSystem::getInstance();
	PathManager& pm = *PathManager::getInstance();
	TableManager& tm = *TableManager::getInstance();
	DirectoryManager& dm = *DirectoryManager::getInstance();

	vector<string> filenames = pm.doAnalyzeFolder( filename );
	vector<string>& pathFiles = *pm.getAllAbsPath( filename );

	Entry* fileEntry;
	
	//int count = pathFiles.size();
	vector<string>::size_type count = pathFiles.size();
	// Ÿ������ ������ �����θ� ���� ���丮�� ã�� ���̳�� ��ȣ�� ����

	*dirInodeNo = dm.returnInodeNum( (char*) pathFiles.at( count -2 ).c_str() );
	// ���丮�� ���̳�� ��ȣ�� ���� ���丮�� �޾ƿ�
	Directory* dir = dm.returnDir( *dirInodeNo );
	fileEntry = dir->findName( (char*)filenames[ filenames.size()-1].c_str() ); // ���丮���� ���Ͽ�Ʈ���� ã��
	//delete dir;

	return fileEntry; // ��� ��� nullptr
}
Exemplo n.º 20
0
std::vector<Robot> Robot::getRobots()
{
  std::vector<Robot> robots;
  std::string robotsDir = "Robots";
  Directory d;
  if(d.open(*File::getFullNames(robotsDir).begin() + "/*"))
  {
    std::string dir;
    bool isDir;
    while(d.read(dir, isDir))
    {
      if(isDir)
      {
        ConfigMap cm;
        std::string s = linuxToPlatformPath(dir + "/robot.cfg");
        int status = cm.read(s);
        if(status > 0)
        {
          Robot r;
          cm >> r;
          robots.push_back(r);
        }
      }
    }
Exemplo n.º 21
0
int main() {
    
    // Model as if there are these four kinds
    // of position in the problem:
    Position boss("Boss", 3141.59);
    Position pointyHair("Pointy Hair", 271.83);
    Position techie("Techie", 14142.13);
    Position peon("Peonissimo", 34.79);
    
    // 
    Directory d;
    d.add("Marilyn", 123, 4567, boss);
    //d.add("John", 321, 7654, boss);
    //d.add("Bob", 234, 9876, boss);
    cout << d << endl;
    Directory d2 = d;	// What function is being used.
    d2.add("Gallagher", 111, 2222, techie);
    cout << d2 << endl;
    Directory d3;
    d3 = d2;
    cout << d3 << endl;

    cout << d3["Marilyn"];
}
Exemplo n.º 22
0
/**
 * \brief Get directory that can be removed
 *			== oldest directory in (sub)tree
 * \return Directory to remove
 */
Directory *Scanner::getDirToRemove()
{
	Directory *dir;
	
	if (!_multiple) {
		/* Only one root directory - good for us */
		dir = getOldestDir(_rootdir);
		if (!dir->isActive()) {
			return dir;
		}
		
		return nullptr;
	}
	
	/* If directory from first subtree cannot be remoevd (e.g. it is active), try next subtree */
	for (auto subRoot: _rootdir->getChildren()) {
		dir = getOldestDir(subRoot);
		if (!dir->isActive()) {
			return dir;
		}
	}
	
	return nullptr;
}
Exemplo n.º 23
0
/*
 *  処理できなかったAPIを標準出力に吐き出す
 */
void ParserComponent::throughConfigurationFile(string & log, Directory & container)
{
    Directory *        node;
    string::size_type  pos;
    string::size_type  begin;
    string::size_type  end;

    pos = 0;
    end = 0;

    node = container[PARSERESULT].getFirstChild();
    while(node != NULL)
    {
        begin = static_cast<string::size_type>((*node)["begin"].toInteger());
        end   = static_cast<string::size_type>((*node)["end"].toInteger());

        if(pos < begin)
            cout << log.substr(pos, begin - pos);

        if(node->toInteger() == 0)
        {
            cout << log.substr(begin, end - begin);
        }else
        {
            for(pos = begin; pos < end; ++pos)
                if( log.at(pos) == '\n' )
                    cout << '\n';
        }
        node = node->getNext();
    }

    if(end < log.size())
        cout << log.substr(end);

    ExceptionMessage("","").throwException();
}
void Directory::GetDataLList( const char *dataName, LList<int> *llist ) const
{
    AppAssert( dataName );
    AppAssert( llist );

    //
    // First try to find a directory representing this LList

    Directory *dir = GetDirectory( dataName );
    if ( !dir )
    {
        AppDebugOut("Failed to find LList %s\n", dataName);
        return;
    }

    //
    // Get info about the LList

    char *tID = dir->GetDataString("tID");
    int size = dir->GetDataInt("Size");
    if ( strcmp(tID, "LList<int>") != 0 || size == DIRECTORY_SAFEINT)
    {
        AppDebugOut("Found object %s but it doesn't appear to be a LList\n");
    }

    //
    // Iterate through it, loading data
    
    for ( int i = 0; i < size; ++i )
    {
        char indexName[16];
        sprintf ( indexName, "[i %d]", i );
        int theData = dir->GetDataInt("indexName");
        llist->PutDataAtEnd( theData );
    }
}
void Directory::WriteXML ( std::ostream &o, int indent ) const
{
    //
    // Print our name

	WriteIndent(o, indent);
	o << '<' << m_name << ">\n";
	
    //
    // 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->WriteXML( o, 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->WriteXML( o, indent + 1 );        
        }
    }	
	
	o << "</" << m_name << ">\n";
}
const EmaString& Channel::toString() const
{
	if ( !_toStringSet )
	{
		_toStringSet = true;
		_toString.set( "\tRsslReactorChannel name " ).append( _name ).append( CR )
			.append( "\tRsslReactor " ).append( ptrToStringAsHex( _pRsslReactor ) ).append( CR )
			.append( "\tRsslReactorChannel " ).append( ptrToStringAsHex( _pRsslChannel ) ).append( CR )
			.append( "\tRsslSocket " ).append( (UInt64)_rsslSocket );

		if ( ! _directoryList.empty() )
		{
			_toString.append( CR ).append( "\tDirectory " );
			Directory* directory = _directoryList.front();
			while ( directory )
			{
                _toString.append( directory->getName() ).append( " " );
				directory = directory->next();
			}
            _toString.append( CR );
		}
	}
	return _toString;
}
Exemplo n.º 27
0
char DirectoryManager::isFile(char* filename, Directory currentDir)
{
	if (strcmp(filename, "/") == 0)
	{
		return 'd';
	}
	Entry* fileEntry = currentDir.findName(filename);
	if (fileEntry == NULL) {
		throw "파일이 존재하지 않습니다.";
	}

	Directory* dir = returnDir(fileEntry->inodeNum);
	if (dir == NULL)
		return 'f';
	return 'd';
}
Exemplo n.º 28
0
/*!	Recursively iterates through the descendents of the given package root node
	and removes all package nodes from the node tree in post-order, until
	encountering \a endPackageNode (if non-null).
	Due to limited kernel stack space we avoid deep recursive function calls
	and rather use the package node stack implied by the tree.
*/
void
Volume::_RemovePackageContentRootNode(Package* package,
	PackageNode* rootPackageNode, PackageNode* endPackageNode, bool notify)
{
	PackageNode* packageNode = rootPackageNode;
	Directory* directory = fRootDirectory;
	directory->WriteLock();

	do {
		if (packageNode == endPackageNode)
			break;

		// recurse into directory
		if (PackageDirectory* packageDirectory
				= dynamic_cast<PackageDirectory*>(packageNode)) {
			if (packageDirectory->FirstChild() != NULL) {
				if (Directory* childDirectory = dynamic_cast<Directory*>(
						directory->FindChild(packageNode->Name()))) {
					directory = childDirectory;
					packageNode = packageDirectory->FirstChild();
					directory->WriteLock();
					continue;
				}
			}
		}

		// continue with the next available (ancestors's) sibling
		do {
			PackageDirectory* packageDirectory = packageNode->Parent();
			PackageNode* sibling = packageDirectory != NULL
				? packageDirectory->NextChild(packageNode) : NULL;

			// we're done with the node -- remove it
			_RemovePackageNode(directory, packageNode,
				directory->FindChild(packageNode->Name()), notify);

			if (sibling != NULL) {
				packageNode = sibling;
				break;
			}

			// no more siblings -- go back up the tree
			packageNode = packageDirectory;
			directory->WriteUnlock();
			directory = directory->Parent();
				// the parent is still locked, so this is safe
		} while (packageNode != NULL/* && packageNode != rootPackageNode*/);
	} while (packageNode != NULL/* && packageNode != rootPackageNode*/);
}
void AddTests3 (Directory &parent)
{
    Directory &dir = parent.GetSubDirectory("linearembedding");

    typedef float Scalar;

    typedef Tenh::BasedVectorSpace_c<Tenh::VectorSpace_c<Tenh::RealField,1,Tenh::Generic>,Tenh::Basis_c<Tenh::Generic>> B1;
    typedef Tenh::BasedVectorSpace_c<Tenh::VectorSpace_c<Tenh::RealField,2,Tenh::Generic>,Tenh::Basis_c<Tenh::Generic>> B2;
    typedef Tenh::BasedVectorSpace_c<Tenh::VectorSpace_c<Tenh::RealField,3,Tenh::Generic>,Tenh::Basis_c<Tenh::Generic>> B3;
    typedef Tenh::BasedVectorSpace_c<Tenh::VectorSpace_c<Tenh::RealField,4,Tenh::Generic>,Tenh::Basis_c<Tenh::Generic>> B4;
    typedef Tenh::BasedVectorSpace_c<Tenh::VectorSpace_c<Tenh::RealField,5,Tenh::Generic>,Tenh::Basis_c<Tenh::Generic>> B5;

    add_checks_for_two_spaces<B3,B1,double>(dir);
    add_checks_for_two_spaces<B3,B2,double>(dir);
    add_checks_for_two_spaces<B3,B4,double>(dir);
    add_checks_for_two_spaces<B3,B5,double>(dir);
}
Exemplo n.º 30
0
bool Directory::createByPath( Directory dir )
{
  Path saveDir = current();
  bool result=true;

  StringArray path = utils::split( dir.toString(), "/" );
  std::string current;
  try
  {
#if  defined(CAESARIA_PLATFORM_UNIX) || defined(CAESARIA_PLATFORM_HAIKU)
    switchTo( "/" );
#endif

    foreach( iter, path )
    {
      current += *iter;
      Path path = current;
      if( path.exist() )
      {
        if( !path.isFolder() )
        {
          Logger::warning( "Current path %s not a directory " + current );
          result = false;
          break;
        }
      }
      else
      {
        if( !create( current ) )
        {
          Logger::warning( "Some error on create directory " + current );
        }
      }
      current += "/";
    }
  }
  catch(...)
  {

  }

  switchTo( saveDir );

  return result;
}