Exemplo n.º 1
3
//----------------------------------------------------------------------
int FFileDialog::changeDir (const FString& dirname)
{
  FString lastdir = directory;
  FString newdir = dirname;

  if ( newdir.includes('~') )
    newdir = newdir.replace('~', getHomeDir());

  if ( newdir[0] == '/' )
    setPath(newdir);
  else
    setPath(directory + newdir);

  switch ( readDir() )
  {
    case -1:
      setPath(lastdir);
      return -1;

    case -2:
      setPath(lastdir);
      readDir();
      return -2;

    case 0:
      if ( newdir == FString("..") )
      {
        if ( lastdir == FString('/') )
          filename.setText('/');
        else
        {
          auto baseName = basename(C_STR(lastdir.c_str()));
          selectDirectoryEntry (baseName);
        }
      }
      else
      {
        FString firstname = dir_entries[0].name;

        if ( dir_entries[0].directory )
          filename.setText(firstname + '/');
        else
          filename.setText(firstname);
      }

      printPath(directory);
      filename.redraw();
      filebrowser.redraw();
      // fall through
    default:
      return 0;
  }
}
Exemplo n.º 2
1
// private methods of FFileDialog
//----------------------------------------------------------------------
void FFileDialog::init()
{
  static constexpr std::size_t w = 42;
  static constexpr std::size_t h = 15;
  int x, y;

  setGeometry(FPoint(1, 1), FSize(w, h), false);
  auto parent_widget = getParentWidget();

  if ( parent_widget )
  {
    x = 1 + int((parent_widget->getWidth() - w) / 2);
    y = 1 + int((parent_widget->getHeight() - h) / 3);
  }
  else
    x = y = 1;

  if ( dlg_type == FFileDialog::Save )
    FDialog::setText("Save file");
  else
    FDialog::setText("Open file");

  widgetSettings (FPoint(x, y));  // Create widgets
  initCallbacks();
  setModal();
  readDir();
}
Exemplo n.º 3
1
//----------------------------------------------------------------------
void FFileDialog::cb_processActivate (FWidget*, FDataPtr)
{
  if ( filename.getText().includes('*')
    || filename.getText().includes('?') )
  {
    setFilter(filename.getText());
    readDir();
    filebrowser.redraw();
  }
  else if ( filename.getText().getLength() == 0 )
  {
    setFilter("*");
    readDir();
    filebrowser.redraw();
  }
  else if ( filename.getText().trim() == FString("..")
         || filename.getText().includes('/')
         || filename.getText().includes('~') )
  {
    changeDir(filename.getText().trim());
  }
  else
  {
    bool found = false;

    if ( ! dir_entries.empty() )
    {
      const auto& input = filename.getText().trim();

      for (auto&& entry : dir_entries)
      {
        if ( entry.name && input && ! input.isNull()
          && std::strcmp(entry.name, input) == 0
          && entry.directory )
        {
          found = true;
          changeDir(input);
          break;
        }
      }
    }

    if ( ! found )
      done (FDialog::Accept);
  }
}
Exemplo n.º 4
0
int printDirs(int fd, int dir_in_location)
{
  int count;
  int dir_count = 0;
  int offset = 0;

  struct ext2_dir_entry_2 dir;

  dir = readDir(fd, dir_in_location, offset);

  while (dir.rec_len != 0)
  {
    printf("\nEntry %d \tInode: %d", dir_count + 1, dir.inode);
    printf("\tName: ");

    for (count = 0; count < dir.name_len; count++)
	{
    printf("%c", dir.name[count]);
	}

    offset = offset + dir.rec_len;
    dir_count = dir_count + 1;
    dir = readDir(fd, dir_in_location, offset);
  }

  return dir_count;
}
Exemplo n.º 5
0
void Watcher::parseEvent(inotify_event *event) {
	std::string fname = watchPath[event->wd];
	fname.append("/").append(event->name);
	switch (event->mask) {
	case IN_MODIFY:
	case IN_CLOSE_WRITE:
	case IN_ATTRIB:
		/*moddified*/
	case IN_CREATE:
	case IN_MOVED_TO:
		/*created*/
	case IN_DELETE:
	case IN_MOVED_FROM:
	default:
		/*deleted*/
		struct stat fstats;
		stat(fname.c_str(), &fstats);
		if (S_ISDIR(fstats.st_mode)) {
			readDir(fname);
		} else if(S_ISREG(fstats.st_mode)) {
			File *fl;
			fl = new File(fname);
			db->insertFileDetails(*fl, *share);
			free(fl);
		} else if (S_ISLNK(fstats.st_mode) && share->isSymlink()) {
			if (lstat(fname.c_str(), &fstats)) {
				std::cerr << "Cant stat symlink" << std::endl;
			}
			if (S_ISDIR(fstats.st_mode)) {
				readDir(fname);
			} else {
				File *fl;
				fl = new File(fname);
				db->insertFileDetails(*fl, *share);
				free(fl);
			}

		}
		std::cout << fname << " Was Changed" << std::endl;
		break;
	case IN_DELETE_SELF:
	case IN_MOVE_SELF:
		inotify_rm_watch(watchfile,event->wd);
		watchPath.erase(event->wd);
		std::cout << watchPath[event->wd] << "was deleted or moved" << std::endl;
		break;
	/*default:
		std::cout << fname << " Something Else Happened - " << event->mask << std::endl;
		throw std::exception();
		break;*/

	}

}
Exemplo n.º 6
0
void QtFileIconView::itemDoubleClicked( QIconViewItem *i )
{
    QtFileIconViewItem *item = ( QtFileIconViewItem* )i;

    if ( item->type() == QtFileIconViewItem::Dir ) {
        viewDir = QDir( item->filename() );
        readDir( viewDir );
    } else if ( item->type() == QtFileIconViewItem::Link &&
                QFileInfo( QFileInfo( item->filename() ).readLink() ).isDir() ) {
        viewDir = QDir( QFileInfo( item->filename() ).readLink() );
        readDir( viewDir );
    }
}
FC_ARSTAT FC_CArDir::createDir(
    const TCHAR*  pszId,
    FC_CArDir**   ppDir
)
{
    FC_ARSTAT   ret;
    FC_CArNode* pPrev;

    *ppDir = NULL;

    if(!m_pAr->isOpenWrite())
        return FC_AR_NOT_OPENED_WRITE;

    if(!FC_StringIsValidFileName(pszId))
        return FC_AR_BAD_FILE_NAME;

    if(!m_pDir && (ret = readDir())!=FC_AR_OK)
        return ret;

    *ppDir = new FC_CArDir(m_pAr, pszId, this, INVALID_HANDLE_VALUE, 0, 0);
    if(m_pDir->insertEx(pszId, *ppDir, true, &pPrev))
    {
        m_nNodes++;
        m_nDirs++;
    }
    else
    {
        if(pPrev->isDir())
            m_nDirs--;
        delete(pPrev);
    }

    m_pAr->setChanged();
    return FC_AR_OK;
}
Exemplo n.º 8
0
void TocManager::readDir(const char *path, TocNode **node, int level) {
	if (level <= 2) { // we don't scan deeper than that
		iox_dirent_t dirent;
		int fd = fio.dopen(path);
		if (fd >= 0) {
			while (fio.dread(fd, &dirent) > 0)
				if (dirent.name[0] != '.') { // skip '.' and '..'
					*node = new TocNode;
					(*node)->sub = (*node)->next = NULL;

					(*node)->nameLen = strlen(dirent.name);
					memcpy((*node)->name, dirent.name, (*node)->nameLen + 1);

					if (dirent.stat.mode & FIO_S_IFDIR) { // directory
						(*node)->isDir = true;
						char nextPath[256];
						sprintf(nextPath, "%s%s/", path, dirent.name);
						readDir(nextPath, &((*node)->sub), level + 1);
					} else
						(*node)->isDir = false;
					node = &((*node)->next);
				}
			fio.dclose(fd);
		} else
			printf("Can't open path: %s\n", path);
	}
}
Exemplo n.º 9
0
/** Checks that the basename component of the input path exactly
 * matches the canonical case of the path on disk.
 * It only makes sense to call this function on a case insensitive filesystem.
 * If the case does not match, throws an exception. */
static void checkCanonicalBaseName(const char *path) {
#ifdef __APPLE__
  struct attrlist attrlist;
  struct {
    uint32_t len;
    attrreference_t ref;
    char canonical_name[WATCHMAN_NAME_MAX];
  } vomit;
  w_string_piece pathPiece(path);
  auto base = pathPiece.baseName();

  memset(&attrlist, 0, sizeof(attrlist));
  attrlist.bitmapcount = ATTR_BIT_MAP_COUNT;
  attrlist.commonattr = ATTR_CMN_NAME;

  if (getattrlist(path, &attrlist, &vomit, sizeof(vomit), FSOPT_NOFOLLOW) ==
      -1) {
    throw std::system_error(errno, std::generic_category(),
                            to<std::string>("checkCanonicalBaseName(", path,
                                            "): getattrlist failed"));
  }

  w_string_piece name(((char *)&vomit.ref) + vomit.ref.attr_dataoffset);
  if (name != base) {
    throw std::system_error(
        ENOENT, std::generic_category(),
        to<std::string>("checkCanonicalBaseName(", path, "): (", name,
                        ") doesn't match canonical base (", base, ")"));
  }
#else
  // Older Linux and BSDish systems are in this category.
  // This is the awful portable fallback used in the absence of
  // a system specific way to detect this.
  w_string_piece pathPiece(path);
  auto parent = pathPiece.dirName().asWString();
  auto dir = w_dir_open(parent.c_str());
  auto base = pathPiece.baseName();

  while (true) {
    auto ent = dir->readDir();
    if (!ent) {
      // We didn't find an entry that exactly matched -> fail
      throw std::system_error(
          ENOENT, std::generic_category(),
          to<std::string>("checkCanonicalBaseName(", path,
                          "): no match found in parent dir"));
    }
    // Note: we don't break out early if we get a case-insensitive match
    // because the dir may contain multiple representations of the same
    // name.  For example, Bash-for-Windows has dirs that contain both
    // "pod" and "Pod" dirs in its perl installation.  We want to make
    // sure that we've observed all of the entries in the dir before
    // giving up.
    if (w_string_piece(ent->d_name) == base) {
      // Exact match; all is good!
      return;
    }
  }
#endif
}
Exemplo n.º 10
0
MtpObjectHandleList* MtpStorage::getObjectList(MtpStorageID storageID, MtpObjectHandle parent) {
	MTPD("MtpStorage::getObjectList, parent: %u\n", parent);
	//append object id  (numerical #s) of database to int array
	MtpObjectHandleList* list = new MtpObjectHandleList();
	if (parent == MTP_PARENT_ROOT) {
		MTPD("parent == MTP_PARENT_ROOT\n");
		parent = 0;
	}

	if (mtpmap.find(parent) == mtpmap.end()) {
		MTPE("parent handle not found, returning empty list\n");
		return list;
	}

	Tree* tree = mtpmap[parent];
	if (!tree->wasAlreadyRead())
	{
		std::string path = getNodePath(tree);
		MTPD("reading directory on demand for tree %p (%u), path: %s\n", tree, tree->Mtpid(), path.c_str());
		readDir(path, tree);
	}

	mtpmap[parent]->getmtpids(list);
	MTPD("returning %u objects in %s.\n", list->size(), tree->getName().c_str());
	return list;
}
Exemplo n.º 11
0
void Finger::printDir(bool newL)
{
    MYSERIAL.print("Dir ");
    MYSERIAL.print(_dirString[readDir()]);
    MYSERIAL.print("  ");
    if(newL)
        MYSERIAL.print("\n");
}
Exemplo n.º 12
0
void
CollectionScanner::doJob() //SLOT
{
    std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
    std::cout << "<scanner>";


    QStringList entries;

    if( m_restart ) {
        QFile logFile( m_logfile );
        logFile.open( IO_ReadOnly );
        QString lastFile = logFile.readAll();

        QFile folderFile( amaroK::saveLocation( QString::null ) + "collection_scan.files"   );
        folderFile.open( IO_ReadOnly );
        entries = QStringList::split( "\n", folderFile.readAll() );

        for( int count = entries.findIndex( lastFile ) + 1; count; --count )
            entries.pop_front();

//         debug() << "Restarting at: " << entries.front() << endl;
    }
    else {
        foreachType( QStringList, m_folders ) {
            if( (*it).isEmpty() )
                //apparently somewhere empty strings get into the mix
                //which results in a full-system scan! Which we can't allow
                continue;

            QString dir = *it;
            if( !dir.endsWith( "/" ) )
                dir += '/';

            readDir( dir, entries );
        }

        QFile folderFile( amaroK::saveLocation( QString::null ) + "collection_scan.files"   );
        folderFile.open( IO_WriteOnly );
        QTextStream stream( &folderFile );
        stream << entries.join( "\n" );
        folderFile.close();
    }

    if( !entries.isEmpty() ) {
        if( !m_restart ) {
            AttributeMap attributes;
            attributes["count"] = QString::number( entries.count() );
            writeElement( "itemcount", attributes );
        }

        scanFiles( entries );
    }

    std::cout << "</scanner>" << std::endl;

    quit();
}
int main(int argc, char * argv[]){

	parseArgs(argc, argv);
	//while(1){
		readDir(file_path);
	//	getPath();
	//}
	return EXIT_SUCCESS;
}
Exemplo n.º 14
0
//----------------------------------------------------------------------
bool FFileDialog::setShowHiddenFiles (bool enable)
{
  if ( show_hidden == enable )
    return show_hidden;

  show_hidden = enable;
  readDir();
  filebrowser.redraw();
  return show_hidden;
}
Exemplo n.º 15
0
void
CollectionScanner::readDir( const QString& dir, QStringList& entries )
{
    // linux specific, but this fits the 90% rule
    if( dir.startsWith( "/dev" ) || dir.startsWith( "/sys" ) || dir.startsWith( "/proc" ) )
        return;
    QDir d( dir );
    m_scannedFolders << d.canonicalPath();

    if( !d.exists() )
        return;
    AttributeHash attributes;
    if( m_batch && !m_rpath.isEmpty() )
    {
        QString rdir = dir;
        rdir.remove( QDir::cleanPath( QDir::currentPath() ) );
        rdir.prepend( QDir::cleanPath( m_rpath + '/' ) );
        attributes["path"] = rdir;
    }
    else
        attributes["path"] = dir;
    writeElement( "folder", attributes );
    d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Readable );
    QFileInfoList list = d.entryInfoList();
    foreach( QFileInfo f, list )
    {
        if( !f.exists() )
            break;

        if( f.isSymLink() )
            f = QFileInfo( f.symLinkTarget() );
        
        if( f.isDir() && m_recursively && !m_scannedFolders.contains( f.canonicalFilePath() ) )
        {
            //The following D-Bus call is used to see if a found folder is new or not
            //During an incremental scan the scanning isn't really recursive, as all folders
            //are stored in the database (even folders implicitly selected by top-level directories)
            //if recursive scanning is selected.  So we don't scan recursively because if any of those
            //folders have updates ScanManager has already figured it out.  Hence why we only scan
            //if isDirInCollection is false: it means the directory is new and we don't know about it
            bool isInCollection = false;
            if( m_incremental && m_amarokCollectionInterface )
            {
                QDBusReply<bool> reply = m_amarokCollectionInterface->call( "isDirInCollection", f.canonicalFilePath() );
                if( reply.isValid() )
                    isInCollection = reply.value();
            }

            if( !m_incremental || !isInCollection )
                readDir( f.absoluteFilePath() + '/', entries );
        }
        else if( f.isFile() )
            entries.append( f.absoluteFilePath() );
    }
}
Exemplo n.º 16
0
FileBrowser::FileBrowser(const QString &name_filter, QWidget *parent)
    : QListWidget(parent)
{
    m_name_filter = name_filter;
    readDir(QDir::currentPath());
    
    connect(this, SIGNAL(itemActivated(QListWidgetItem *)),
            this, SLOT(activatedSlot(QListWidgetItem *)));
    connect(this, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
            this, SLOT(currentChangedSlot(QListWidgetItem *)));
}
Exemplo n.º 17
0
void FileBrowser::activatedSlot(QListWidgetItem *itm)
{
    if (!itm)
        return;
    
    QString name = itm->text();
    QString path = m_path + "/" + name;
    
    if (QFileInfo(path).isDir())
    	readDir(path);
}
Exemplo n.º 18
0
void TocManager::readEntries(const char *root) {
    _rootLen = strlen(root);
	strcpy(_root, root);
	while (_root[_rootLen - 1] == '/') {
		_rootLen--;
		_root[_rootLen] = '\0';
	}
	char readPath[256];
	sprintf(readPath, "%s/", _root);
	printf("readDir: %s\n", readPath);
	readDir(readPath, &_rootNode, 0);
}
Exemplo n.º 19
0
int IS_exist(int i_node,char * file)
{
    dirnode.offset=0;
    lseek(devfd[dev],get_inode_address(i_node),SEEK_SET);
    read(devfd[dev],dirnode.INODE,sizeof(dirnode.INODE));
    while(readDir(&dirnode,&dentry)!=-1)
    {
            if(strcmp(dentry.dirname,file)==0)
            {
                return dentry.d_ino;
            }
    }
    return -1;
}
Exemplo n.º 20
0
FC_ARSTAT FC_CArDir::countSubDirs(int* pnDirs)
{
    FC_ARSTAT ret;

    *pnDirs = 0;

    if(!m_pDir && (ret = readDir()) != FC_AR_OK)
        return ret;

    assert(m_nDirs>=0);
    *pnDirs = m_nDirs;

    return FC_AR_OK;
}
void readDir(char* dir){
	DIR* directory;
	struct dirent* entry;
	int count = 0;
	size_t length;
	length = strlen(dir);
	if (dir[length - 1] != '/') {
    		dir[length] = '/';
    		dir[length + 1] = '\0';
    		++length;
  	}
	if((directory = opendir(dir)) == NULL){
		perror("opendir");
		exit(EXIT_FAILURE);
	}

	struct stat st;
	char file[PATH_MAX + 1];
	strcpy(file, dir);

	while(( entry = readdir(directory)) != NULL) {
		if(strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0){
    			strncpy(file + length, entry->d_name, sizeof(file) - length);
    			lstat (file, &st);
			if(S_ISDIR(st.st_mode)){
				pid_t pid = fork(); //musi byt aby sme mohli rekurzivne volat(nemoze byt otvorenzch tolko dir jednym porcesom
				if(!pid){
					readDir(file);
					exit(EXIT_SUCCESS);
				} else {
					wait(NULL);
				}
			}
			if(S_ISLNK(st.st_mode)){
				if(!(exist_ || not_exist_))
					fprintf(stderr, "%s\n", file);
				if(exist_ && access(file, F_OK) == 0)
					count++;
				if(not_exist_ && access(file, F_OK) == -1 && errno == ENOENT)
					count++; 
			}
		}
	}	
	if(exist_ || not_exist_)
		fprintf(stderr,"# of symlinks is %i\n", count);
	if(closedir(directory) != 0 ) {
		perror("closedir");
		exit(EXIT_FAILURE);
	}
}
Exemplo n.º 22
0
Foam::IOobjectList::IOobjectList
(
    const objectRegistry& db,
    const fileName& instance,
    const fileName& local,
    IOobject::readOption r,
    IOobject::writeOption w,
    bool registerObject
)
:
    HashPtrTable<IOobject>()
{
    word newInstance = instance;

    if (!isDir(db.path(instance)))
    {
        newInstance = db.time().findInstancePath(instant(instance));

        if (newInstance.empty())
        {
            return;
        }
    }

    // Create a list of file names in this directory
    fileNameList ObjectNames =
        readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);

    forAll(ObjectNames, i)
    {
        IOobject* objectPtr = new IOobject
        (
            ObjectNames[i],
            newInstance,
            local,
            db,
            r,
            w,
            registerObject
        );

        if (objectPtr->headerOk())
        {
            insert(ObjectNames[i], objectPtr);
        }
        else
        {
            delete objectPtr;
        }
    }
Exemplo n.º 23
0
clusterAnaliz::clusterAnaliz(std::string directory) {

	std::vector<std::string> fileNames = readDir(directory);

	for (size_t i = 2; i < fileNames.size(); ++i) {
		std::string name = directory + fileNames[i];
		std::cout << name << std::endl;
		text t = text(name);
		texts.push_back(t);
	}

	for (int i = 0; i < texts.size(); ++i) {
		findTextMass(i);
	}
}
Exemplo n.º 24
0
FC_ARSTAT FC_CArDir::getFilesToDisk(
    const TCHAR*             pszDirectory,
    const TCHAR*             pszFileSpec, //NULL (same as "*") or any *? pattern
    bool                     bRecursive,
    FC_CGArray<FC_CArNode*>* pFileList
)
{
    FC_ARSTAT   ret;
    FC_CArDir*  pDir;
    FC_CString  currDiskPath(MAX_PATH);
    const FC_CHashStr<FC_CArNode*>::Pair* pp;

    if(!m_pDir && (ret = readDir()) != FC_AR_OK)
        return ret;

    currDiskPath.load(pszDirectory);


    for(pp=m_pDir->firstPair(); pp; pp=pp->pNext)
    {
        pDir = pp->pVal->isDir();
        if(pDir)
        {
            if(bRecursive)
            {
                currDiskPath.addc(_T('\\'))<<pp->pszKey;
                ret = pDir->getFilesToDisk(currDiskPath, pszFileSpec, bRecursive, pFileList);
                if(ret != FC_AR_OK)
                    return ret;
                currDiskPath.stripFilePart();
            }
        }
        else
        {
            if(!pszFileSpec || FC_StringMatchFilePattern(pp->pszKey, pszFileSpec))
            {
                if(pFileList)
                    pFileList->add(pp->pVal);

                ret = pp->pVal->isFile()->getToDisk(currDiskPath, NULL);
                if(ret != FC_AR_OK)
                    return ret;
            }
        }
    }

    return FC_AR_OK;
}
Exemplo n.º 25
0
FC_ARSTAT FC_CArDir::getSubDir(const TCHAR* pszId, FC_CArDir** ppDir)
{
    FC_ARSTAT   ret;
    FC_CArNode* pNode;

    *ppDir = NULL;

    if(!m_pDir && (ret = readDir()) != FC_AR_OK)
        return ret;

    pNode = m_pDir->get(pszId);
    if(pNode)
        *ppDir = pNode->isDir();

    return FC_AR_OK;
}
Exemplo n.º 26
0
FC_ARSTAT FC_CArDir::getFile(const TCHAR* pszId, FC_CArFile** ppFile)
{
    FC_ARSTAT   ret;
    FC_CArNode* pNode;

    *ppFile = NULL;

    if(!m_pDir && (ret = readDir()) != FC_AR_OK)
        return ret;

    pNode = m_pDir->get(pszId);
    if(pNode)
        *ppFile = pNode->isFile();

    return FC_AR_OK;
}
Exemplo n.º 27
0
FC_ARSTAT FC_CArDir::createFile(
    const TCHAR* pszId,
    const TCHAR* pszDiskFile,
    DWORD        dwBytes,
    const void*  pvData
)
{
    FC_ARSTAT   ret;
    FC_CArFile* pNew;
    FC_CArNode* pPrev;
    DWORD       dwOffset;
    HANDLE      hFileTmp;

    if(m_pAr->m_firstFatalError != FC_AR_OK)
        return FC_AR_ERR_INERROR;

    if(!m_pAr->isOpenWrite())
        return FC_AR_NOT_OPENED_WRITE;

    if(!pszId)
        pszId = FC_StringGetFilePart(pszDiskFile);

    if(!FC_StringIsValidFileName(pszId))
        return FC_AR_BAD_FILE_NAME;

    if(!m_pDir && (ret = readDir())!=FC_AR_OK)
        return ret;

    ret = m_pAr->writeToTmp(pvData, pszDiskFile, &dwBytes, &dwOffset, &hFileTmp);
    if(ret!=FC_AR_OK)
        return ret;

    pNew = new FC_CArFile(pszId, this, hFileTmp, dwBytes, dwOffset, &m_pAr->m_firstFatalError);
    if(m_pAr->m_firstFatalError != FC_AR_OK)
    {
        m_pAr->setChanged();
        delete(pNew);
        return m_pAr->m_firstFatalError;
    }
    if(m_pDir->insertEx(pszId, pNew, true, &pPrev))
        m_nNodes++;
    else
        delete(pPrev);

    m_pAr->setChanged();
    return FC_AR_OK;
}
Exemplo n.º 28
0
void SFtpFileEngine::refreshFileInfoCache(const QString &path)
{
    if (_path == path)
    {
        refreshFileInfoCache();

        return;
    }

    // failed to connect or to login ?
    if (!sftpConnect())
        return;

    readDir(PathComp(path).dir());

    sftpDisconnect();
}
Exemplo n.º 29
0
//int sendAsset(int sockfd, http_request_t* http_request)
void sendAsset(http_request_t* http_request)
{
    char directory[] = "scripts/Assets";
    int file_count;
    int i;

    printf("%s\n", http_request->request_uri);
    
    file_count = NumberOfFiles(directory);
    char filelist[file_count];

    readDir(directory, file_count, filelist);

    for(i=1; i <= sizeof(filelist); i++){
        printf("%s", filelist[i]);
    }
}
Exemplo n.º 30
0
Foam::IOobjectList::IOobjectList
(
    const objectRegistry& db,
    const fileName& instance,
    const fileName& local
)
:
    HashPtrTable<IOobject>()
{
    word newInstance = instance;

    if (!isDir(db.path(instance)))
    {
        newInstance = db.time().findInstancePath(instant(instance));

        if (newInstance.empty())
        {
            return;
        }
    }

    // Create list file names in directory
    fileNameList ObjectNames =
        readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);

    forAll(ObjectNames, i)
    {
        IOobject* objectPtr = new IOobject
        (
            ObjectNames[i],
            newInstance,
            local,
            db,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );

        if (objectPtr->headerOk())
        {
            insert(ObjectNames[i], objectPtr);
        }
        else
        {
            delete objectPtr;
        }
    }