Ejemplo n.º 1
0
void SelectResourceImage::listDirectory(QDir dir, QStandardItem *parentItem, const QString& pathPrefix)
{
    QStringList dirs=dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
    QStringList filters;
    filters<<"*.png"<<"*.jpg"<<"*.bmp"<<"*.svg"<<"*.tif";
    QStringList files=dir.entryList(filters,QDir::Files,QDir::Name);
    for (int i = 0; i < dirs.size(); ++i) {
        QStandardItem *item = new QStandardItem(dirs[i]);
        item->setData(dir.absolutePath()+"/"+dirs[i]+"/");
        item->setData(false, Qt::UserRole+2);
        item->setIcon(QIcon(":/lib/file_opendir.png"));
        parentItem->appendRow(item);
        QDir d=dir;
        d.cd(dirs[i]);
        if (pathPrefix.isEmpty()) {
            listDirectory(d, item, "");
        } else {
            listDirectory(d, item, pathPrefix+dirs[i]+"/");
        }
    }
    for (int i = 0; i < files.size(); ++i) {
        QString abspath=dir.absoluteFilePath(files[i]);
        QStandardItem *item = new QStandardItem(QIcon(abspath), files[i]);
        item->setData(true, Qt::UserRole+2);
        if (pathPrefix.isEmpty()) {
            item->setData(abspath);
        } else {
            item->setData(pathPrefix+files[i]);
        }
        parentItem->appendRow(item);
    }
}
Ejemplo n.º 2
0
  boolean get_handler(AtMegaWebServer& web_server){
	const char* filename = web_server.get_path();
#if DEBUG
	Serial << F("file_handler path: ") << filename << '\n';
#endif

  if (!filename) {
    web_server.sendHttpResult(404);
#if DEBUG
    Serial << F("Could not parse URL");
#endif
    return true;
  }

  if(filename[0] == '/' && filename[1] == 0){ // root dir, file.open() will fail
    listDirectory(web_server, SdBaseFile::cwd());
	return true;
  }

  SdFile file;
  if(file.open(filename, O_READ)){
#if DEBUG
     Serial << "file isOpen: " << filename << '\n';
#endif
	  if (file.isDir())
	  {
		listDirectory(web_server, &file);
	  }
	  else
	  {
		AtMegaWebServer::MimeType mime_type
		  = AtMegaWebServer::get_mime_type_from_filename(filename);

  // If you want to send a file with a non-supported MimeType you can:
  // web_server.sendHttpResult(200, 0, "Content-Type: image/tiff" CRLF);

        web_server.sendHttpResult(200, mime_type);
#if DEBUG
		Serial << F("Read file ");
		Serial.println(filename);
#endif
		web_server.send_file(file);
	  }
	  file.close();
    }else{
      web_server.sendHttpResult(404);
    }
    return true;
}
void LocalStorageDatabaseTracker::updateTrackerDatabaseFromLocalStorageDatabaseFiles()
{
    Vector<String> paths = listDirectory(m_localStorageDirectory, "*.localstorage");

    HashSet<String> origins(m_origins);
    HashSet<String> originsFromLocalStorageDatabaseFiles;

    for (size_t i = 0; i < paths.size(); ++i) {
        const String& path = paths[i];

        if (!path.endsWith(".localstorage"))
            continue;

        String filename = pathGetFileName(path);

        String originIdentifier = filename.substring(0, filename.length() - strlen(".localstorage"));

        if (!m_origins.contains(originIdentifier))
            addDatabaseWithOriginIdentifier(originIdentifier, path);

        originsFromLocalStorageDatabaseFiles.add(originIdentifier);
    }

    for (auto it = origins.begin(), end = origins.end(); it != end; ++it) {
        const String& originIdentifier = *it;
        if (origins.contains(originIdentifier))
            continue;

        removeDatabaseWithOriginIdentifier(originIdentifier);
    }
}
Ejemplo n.º 4
0
static void removeAllDatabasesForOriginPath(const String& originPath, double startDate, double endDate)
{
    // FIXME: We should also close/invalidate any live handles to the database files we are about to delete.
    // Right now:
    //     - For read-only operations, they will continue functioning as normal on the unlinked file.
    //     - For write operations, they will start producing errors as SQLite notices the missing backing store.
    // This is tracked by https://bugs.webkit.org/show_bug.cgi?id=135347

    Vector<String> databasePaths = listDirectory(originPath, "*");

    for (auto& databasePath : databasePaths) {
        String databaseFile = pathByAppendingComponent(databasePath, "IndexedDB.sqlite3");

        if (!fileExists(databaseFile))
            continue;

        time_t modTime;
        getFileModificationTime(databaseFile, modTime);

        if (modTime < startDate || modTime > endDate)
            continue;

        deleteFile(databaseFile);
        deleteEmptyDirectory(databasePath);
    }

    deleteEmptyDirectory(originPath);
}
Ejemplo n.º 5
0
static void removeAllDatabasesForOriginPath(const String& originPath, std::chrono::system_clock::time_point modifiedSince)
{
    Vector<String> databasePaths = listDirectory(originPath, "*");

    for (auto& databasePath : databasePaths) {
        String databaseFile = pathByAppendingComponent(databasePath, "IndexedDB.sqlite3");

        if (!fileExists(databaseFile))
            continue;

        if (modifiedSince > std::chrono::system_clock::time_point::min()) {
            time_t modificationTime;
            if (!getFileModificationTime(databaseFile, modificationTime))
                continue;

            if (std::chrono::system_clock::from_time_t(modificationTime) < modifiedSince)
                continue;
        }

        SQLiteFileSystem::deleteDatabaseFile(databaseFile);
        deleteEmptyDirectory(databasePath);
    }

    deleteEmptyDirectory(originPath);
}
Ejemplo n.º 6
0
void Particles::init(){
	/// collect textures
	std::vector<std::string> &&images = listDirectory("../res/textures/CGI256"s);
	ResourceLoader loader;
	Global::main.commonResources.textureAtlas["Cgi256"] = loader.loadAtlas(images, "../res/textures/CGI256"s);
	createBuffer();
}
Ejemplo n.º 7
0
void RemoteBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
	switch (cmd) {
	case kChooseCmd: {
		// If nothing is selected in the list widget, choose the current dir.
		// Else, choose the dir that is selected.
		int selection = _fileList->getSelected();
		if (selection >= 0)
			_choice = _nodeContent[selection];
		else
			_choice = _node;
		setResult(1);
		close();
		break;
	}
	case kGoUpCmd:
		goUp();
		break;
	case kListItemActivatedCmd:
	case kListItemDoubleClickedCmd:
		if (_nodeContent[data].isDirectory()) {
			_rememberedNodeContents[_node.path()] = _nodeContent;
			listDirectory(_nodeContent[data]);
		}
		break;
	case kListSelectionChangedCmd:
		// We do not allow selecting directories,
		// thus we will invalidate the selection
		// when the user selects a directory over here.
		if (data != (uint32)-1 && !_nodeContent[data].isDirectory())
			_fileList->setSelected(-1);
		break;
	default:
		Dialog::handleCommand(sender, cmd, data);
	}
}
Ejemplo n.º 8
0
SelectResourceImage::SelectResourceImage(const QString &directory, QWidget *parent, const QString& pathPrefix) :
    QFDialog(parent),
    ui(new Ui::SelectResourceImage)
{
    ui->setupUi(this);
    connect(ui->treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(treeClicked(QModelIndex)));
    connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(listDoubleClicked(QModelIndex)));


    QStandardItem *parentItem = model.invisibleRootItem();
    listDirectory(QDir(directory), parentItem, pathPrefix);
    ui->treeView->setModel(&model);
    ui->listView->setModel(&model);
    ui->listView->setRootIndex(model.index(0,0));
    ui->spinIconSize->setValue(16);


    isMulti=false;
    ProgramOptions::getConfigWindowGeometry(this, "SelectResourceImage/window");
    ProgramOptions::getConfigQSplitter(ui->splitter, "SelectResourceImage/splitter");
    ProgramOptions::getConfigQSpinBox(ui->spinIconSize, "SelectResourceImage/spinIconSize");
    ProgramOptions::getConfigQToolButton(ui->btnLarge, "SelectResourceImage/btnLarge");
    ProgramOptions::getConfigQToolButton(ui->btnList, "SelectResourceImage/btnList");
    ProgramOptions::getConfigQToolButton(ui->btnTreeOnly, "SelectResourceImage/btnTreeOnly");
    updateView();
    setWindowFlags(windowFlags()|Qt::WindowMinMaxButtonsHint);
}
Ejemplo n.º 9
0
void DU_File::listDirectory(const string &path, vector<string> &files, bool bRecursive)
{
    vector<string> tf;
    scanDir(path, tf, 0, 0);

    for(size_t i = 0; i < tf.size(); i++)
    {
        if(tf[i] == "." || tf[i] == "..")
            continue;

        string s = path + "/" + tf[i];

        if(isFileExist(s, S_IFDIR))
        {
            files.push_back(simplifyDirectory(s));
            if(bRecursive)
            {
                listDirectory(s, files, bRecursive);
            }
        }
        else
        {
            files.push_back(simplifyDirectory(s));
        }
    }
}
Ejemplo n.º 10
0
Vector<SecurityOriginData> DatabaseProcess::getIndexedDatabaseOrigins()
{
    Vector<SecurityOriginData> results;

    if (m_indexedDatabaseDirectory.isEmpty()) {
        return results;
    }

    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
    for (auto& originPath : originPaths) {
        URL url;
        url.setProtocol(ASCIILiteral("file"));
        url.setPath(originPath);

        String databaseIdentifier = url.lastPathComponent();

        RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::maybeCreateFromDatabaseIdentifier(databaseIdentifier);
        if (!securityOrigin)
            continue;

        results.append(SecurityOriginData::fromSecurityOrigin(securityOrigin.get()));
    }

    return results;
}
Ejemplo n.º 11
0
static int _testListInvalidDirectory(void) {
  CharString c = newCharStringWithCString("invalid");
  LinkedList l = listDirectory(c);
  assertIntEquals(linkedListLength(l), 0);
  freeLinkedList(l);
  freeCharString(c);
  return 0;
}
void listDirectory(const std::string& path, Vector<std::string>& list) {
    std::vector<std::string> vec;
    listDirectory(path, vec);
    list.clear();
    for (std::string file : vec) {
        list.add(file);
    }
}
Ejemplo n.º 13
0
TEST(FileUtils, Listdirectory)
{
  std::string directory = "test/zip";
  
  std::vector<std::string> result = listDirectory(directory);

  ASSERT_EQ(1, result.size());
}
Ejemplo n.º 14
0
void DatabaseProcess::deleteIndexedDatabaseEntriesModifiedBetweenDates(double startDate, double endDate)
{
    if (m_indexedDatabaseDirectory.isEmpty())
        return;

    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
    for (auto& originPath : originPaths)
        removeAllDatabasesForOriginPath(originPath, startDate, endDate);
}
Ejemplo n.º 15
0
void DatabaseProcess::deleteAllIndexedDatabaseEntries()
{
    if (m_indexedDatabaseDirectory.isEmpty())
        return;

    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
    for (auto& originPath : originPaths)
        removeAllDatabasesForOriginPath(originPath, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
}
Ejemplo n.º 16
0
void DatabaseProcess::deleteIndexedDatabaseEntriesModifiedSince(std::chrono::system_clock::time_point modifiedSince)
{
    if (m_indexedDatabaseDirectory.isEmpty())
        return;

    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
    for (auto& originPath : originPaths)
        removeAllDatabasesForOriginPath(originPath, modifiedSince);
}
Ejemplo n.º 17
0
void IDBServer::performCloseAndDeleteDatabasesModifiedSince(std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
{
    if (!m_databaseDirectoryPath.isEmpty()) {
        Vector<String> originPaths = listDirectory(m_databaseDirectoryPath, "*");
        for (auto& originPath : originPaths)
            removeAllDatabasesForOriginPath(originPath, modifiedSince);
    }

    postDatabaseTaskReply(createCrossThreadTask(*this, &IDBServer::didPerformCloseAndDeleteDatabases, callbackID));
}
Ejemplo n.º 18
0
static int _testListEmptyDirectory(void) {
  CharString tempDir = _fileUtilitiesMakeTempDir();
  LinkedList l = listDirectory(tempDir);

  assertIntEquals(linkedListLength(l), 0);
  removeDirectory(tempDir);

  freeCharString(tempDir);
  freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString);
  return 0;
}
Ejemplo n.º 19
0
unsigned long long DatabaseTracker::usageForOrigin(SecurityOrigin* origin)
{
    String originPath = this->originPath(origin);
    unsigned long long diskUsage = 0;
    for (auto& fileName : listDirectory(originPath, ASCIILiteral("*.db"))) {
        long long size;
        getFileSize(fileName, size);
        diskUsage += size;
    }
    return diskUsage;
}
Ejemplo n.º 20
0
void FilesPageHandler::handle(Client &client) {
	Common::String response =
		"<html>" \
		"<head><title>ScummVM</title></head>" \
		"<body>" \
		"<p>{create_directory_desc}</p>" \
		"<form action=\"create\">" \
		"<input type=\"hidden\" name=\"path\" value=\"{path}\"/>" \
		"<input type=\"text\" name=\"directory_name\" value=\"\"/>" \
		"<input type=\"submit\" value=\"{create_directory_button}\"/>" \
		"</form>" \
		"<hr/>" \
		"<p>{upload_file_desc}</p>" \
		"<form action=\"upload?path={path}\" method=\"post\" enctype=\"multipart/form-data\">" \
		"<input type=\"file\" name=\"upload_file-f\" allowdirs multiple/>" \
		"<span>{or_upload_directory_desc}</span>" \
		"<input type=\"file\" name=\"upload_file-d\" directory webkitdirectory multiple/>" \
		"<input type=\"submit\" value=\"{upload_file_button}\"/>" \
		"</form>"
		"<hr/>" \
		"<h1>{index_of_directory}</h1>" \
		"<table>{content}</table>" \
		"</body>" \
		"</html>";
	Common::String itemTemplate = "<tr><td><img src=\"icons/{icon}\"/></td><td><a href=\"{link}\">{name}</a></td><td>{size}</td></tr>\n"; //TODO: load this template too?

																																		  // load stylish response page from the archive
	Common::SeekableReadStream *const stream = HandlerUtils::getArchiveFile(FILES_PAGE_NAME);
	if (stream)
		response = HandlerUtils::readEverythingFromStream(stream);

	Common::String path = client.queryParameter("path");
	Common::String content = "";

	// show an error message if failed to list directory
	if (!listDirectory(path, content, itemTemplate)) {
		HandlerUtils::setFilesManagerErrorMessageHandler(client, _("ScummVM couldn't list the directory you specified."));
		return;
	}

	//these occur twice:
	replace(response, "{create_directory_button}", _("Create directory"));
	replace(response, "{create_directory_button}", _("Create directory"));
	replace(response, "{path}", encodeDoubleQuotes(client.queryParameter("path")));
	replace(response, "{path}", encodeDoubleQuotes(client.queryParameter("path")));
	replace(response, "{upload_files_button}", _("Upload files")); //tab
	replace(response, "{upload_file_button}", _("Upload files")); //button in the tab
	replace(response, "{create_directory_desc}", _("Type new directory name:"));
	replace(response, "{upload_file_desc}", _("Select a file to upload:"));
	replace(response, "{or_upload_directory_desc}", _("Or select a directory (works in Chrome only):"));
	replace(response, "{index_of_directory}", Common::String::format(_("Index of %s"), encodeHtmlEntities(getDisplayPath(client.queryParameter("path"))).c_str()));
	replace(response, "{content}", content);
	LocalWebserver::setClientGetHandler(client, response);
}
Ejemplo n.º 21
0
SelectResourceImage::SelectResourceImage(const QStringList &directories, QWidget *parent, const QStringList &pathPrefixes, const QStringList &baseNodeNames) :
    QFDialog(parent),
    ui(new Ui::SelectResourceImage)
{
    ui->setupUi(this);
    connect(ui->treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(treeClicked(QModelIndex)));
    connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(listDoubleClicked(QModelIndex)));


    if (baseNodeNames.isEmpty()) {
        QStandardItem *parentItem = model.invisibleRootItem();
        for (int i=0; i<directories.size(); i++) {
            listDirectory(QDir(directories[i]), parentItem, pathPrefixes.value(i, ""));
        }
    } else {
        QStandardItem *inv = model.invisibleRootItem();
        for (int i=0; i<directories.size(); i++) {
            QStandardItem *parentItem=new QStandardItem(baseNodeNames.value(i, tr("group %1").arg(i+1)));
            parentItem->setData(false, Qt::UserRole+2);
            parentItem->setData(QDir(directories[i]).absolutePath());
            inv->appendRow(parentItem);
            listDirectory(QDir(directories[i]), parentItem, pathPrefixes.value(i, ""));
        }
    }
    ui->treeView->setModel(&model);
    ui->listView->setModel(&model);
    ui->listView->setRootIndex(model.index(0,0));
    ui->btnLarge->setChecked(true);
    ui->spinIconSize->setValue(64);


    isMulti=true;
    ProgramOptions::getConfigWindowGeometry(this, "SelectResourceImageMulti/window");
    ProgramOptions::getConfigQSplitter(ui->splitter, "SelectResourceImageMulti/splitter");
    ProgramOptions::getConfigQSpinBox(ui->spinIconSize, "SelectResourceImageMulti/spinIconSize");
    ProgramOptions::getConfigQToolButton(ui->btnLarge, "SelectResourceImageMulti/btnLarge");
    ProgramOptions::getConfigQToolButton(ui->btnList, "SelectResourceImageMulti/btnList");
    ProgramOptions::getConfigQToolButton(ui->btnTreeOnly, "SelectResourceImageMulti/btnTreeOnly");
    updateView();
    setWindowFlags(windowFlags()|Qt::WindowMinMaxButtonsHint);
}
Ejemplo n.º 22
0
/**
 * Search and release filter object.
 */
size_t File::list(FileList &result, FileFilter *filter) const
{
    try {
        size_t s = listDirectory(result, filter);
        delete filter;
        return s;
    }
    catch (...) {
        delete filter;
        throw;
    }
}
Ejemplo n.º 23
0
Archivo: filelib.c Proyecto: cs50/spl
Iterator newDirectoryIterator(string dir) {
   Iterator iterator;
   string *names;
   int i;

   iterator = newListIterator(sizeof (string), NULL);
   names = listDirectory(dir);
   for (i = 0; names[i] != NULL; i++) {
      addToIteratorList(iterator, &names[i]);
   }
   return iterator;
}
Ejemplo n.º 24
0
Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
{
    Vector<String> result;
    Vector<String> pluginPaths = listDirectory(directory, String("*.so"));
    Vector<String>::const_iterator end = pluginPaths.end();
    for (Vector<String>::const_iterator it = pluginPaths.begin(); it != end; ++it) {
        if (fileExists(*it))
            result.append(*it);
    }

    return result;
}
Ejemplo n.º 25
0
void StorageTracker::syncFileSystemAndTrackerDatabase()
{
    ASSERT(!isMainThread());

    SQLiteTransactionInProgressAutoCounter transactionCounter;

    ASSERT(m_isActive);

    Vector<String> paths;
    {
        MutexLocker locker(m_databaseMutex);
        paths = listDirectory(m_storageDirectoryPath, "*.localstorage");
    }

    // Use a copy of m_originSet to find expired entries and to schedule their
    // deletions from disk and from m_originSet.
    OriginSet originSetCopy;
    {
        MutexLocker locker(m_originSetMutex);
        for (OriginSet::const_iterator it = m_originSet.begin(), end = m_originSet.end(); it != end; ++it)
            originSetCopy.add((*it).isolatedCopy());
    }
    
    // Add missing StorageTracker records.
    OriginSet foundOrigins;
    String fileExtension = ASCIILiteral(".localstorage");

    for (Vector<String>::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) {
        const String& path = *it;

        if (path.length() > fileExtension.length() && path.endsWith(fileExtension, true)) {
            String file = pathGetFileName(path);
            String originIdentifier = file.substring(0, file.length() - fileExtension.length());
            if (!originSetCopy.contains(originIdentifier))
                syncSetOriginDetails(originIdentifier, path);

            foundOrigins.add(originIdentifier);
        }
    }

    // Delete stale StorageTracker records.
    for (OriginSet::const_iterator it = originSetCopy.begin(), end = originSetCopy.end(); it != end; ++it) {
        const String& originIdentifier = *it;
        if (foundOrigins.contains(originIdentifier))
            continue;

        String originIdentifierCopy = originIdentifier.isolatedCopy();
        callOnMainThread([this, originIdentifierCopy] {
            deleteOriginWithIdentifier(originIdentifierCopy);
        });
    }
}
Ejemplo n.º 26
0
/**
 * @brief Recursively lists all directories in the global queue and empties that queue
 */
void list_recursive() {
    DIRENTRY* directoryEntry;

    unsigned int nextCluster;
    while((directoryEntry = dir_pop_front())) {

        nextCluster = directoryEntry->firstcluser;
        do{
            listDirectory(getclusteroffset(nextCluster));
        }while((nextCluster = getnextcluster(nextCluster)) < CLUSTER_LAST_MIN);
        printf("\n");
    }
}
void StorageTracker::syncFileSystemAndTrackerDatabase()
{
    ASSERT(!isMainThread());
    ASSERT(m_isActive);

    m_databaseGuard.lock();
    DEFINE_STATIC_LOCAL(const String, fileMatchPattern, ("*.localstorage"));
    DEFINE_STATIC_LOCAL(const String, fileExt, (".localstorage"));
    DEFINE_STATIC_LOCAL(const unsigned, fileExtLength, (fileExt.length()));
    m_databaseGuard.unlock();

    Vector<String> paths;
    {
        MutexLocker lock(m_databaseGuard);
        paths = listDirectory(m_storageDirectoryPath, fileMatchPattern);
    }

    // Use a copy of m_originSet to find expired entries and to schedule their
    // deletions from disk and from m_originSet.
    OriginSet originSetCopy;
    {
        MutexLocker lock(m_originSetGuard);
        OriginSet::const_iterator end = m_originSet.end();
        for (OriginSet::const_iterator it = m_originSet.begin(); it != end; ++it)
            originSetCopy.add((*it).threadsafeCopy());
    }
    
    // Add missing StorageTracker records.
    OriginSet foundOrigins;
    Vector<String>::const_iterator end = paths.end();
    for (Vector<String>::const_iterator it = paths.begin(); it != end; ++it) {
        String path = *it;
        if (path.endsWith(fileExt, true) && path.length() > fileExtLength) {
            String file = pathGetFileName(path);
            String originIdentifier = file.substring(0, file.length() - fileExtLength);
            if (!originSetCopy.contains(originIdentifier))
                syncSetOriginDetails(originIdentifier, path);

            foundOrigins.add(originIdentifier);
        }
    }

    // Delete stale StorageTracker records.
    OriginSet::const_iterator setEnd = originSetCopy.end();
    for (OriginSet::const_iterator it = originSetCopy.begin(); it != setEnd; ++it) {
        if (!foundOrigins.contains(*it)) {
            RefPtr<StringImpl> originIdentifier = (*it).threadsafeCopy().impl();
            callOnMainThread(deleteOriginOnMainThread, originIdentifier.release().leakRef());
        }
    }
}
Ejemplo n.º 28
0
unsigned long long DatabaseTracker::usageForOrigin(SecurityOrigin* origin)
{
    String originPath = this->originPath(origin);
    unsigned long long diskUsage = 0;
    Vector<String> fileNames = listDirectory(originPath, String("*.db"));
    Vector<String>::iterator fileName = fileNames.begin();
    Vector<String>::iterator lastFileName = fileNames.end();
    for (; fileName != lastFileName; ++fileName) {
        long long size;
        getFileSize(*fileName, size);
        diskUsage += size;
    }
    return diskUsage;
}
Ejemplo n.º 29
0
void IDBServer::performGetAllDatabaseNames(uint64_t serverConnectionIdentifier, const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID)
{
    String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(mainFrameOrigin, openingOrigin, m_databaseDirectoryPath);

    Vector<String> entries = listDirectory(directory, ASCIILiteral("*"));
    Vector<String> databases;
    databases.reserveInitialCapacity(entries.size());
    for (auto& entry : entries) {
        String encodedName = lastComponentOfPathIgnoringTrailingSlash(entry);
        databases.uncheckedAppend(SQLiteIDBBackingStore::databaseNameFromEncodedFilename(encodedName));
    }

    postDatabaseTaskReply(createCrossThreadTask(*this, &IDBServer::didGetAllDatabaseNames, serverConnectionIdentifier, callbackID, databases));
}
Ejemplo n.º 30
0
static void directoryToHTML(const char* path)
{
  LST_HEAD* l;
#if 0
  char topDirectory[1024];
  char currentDirectory[1024];
  char key[1024];
#endif
  FILE_ENTRY* f;
  char parentPath[1024];
  char *c;

  strcpy(parentPath, path);
  c = parentPath + strlen(parentPath);
  while (*(--c) != '/')
    ;
  *c = '\0';

  l = LST_Create();
  listDirectory(path, &l);

  html_header();
  html_begin_body_options("File View", "bgcolor=#ffffff");

  while ((f = LST_Dequeue(&l)) != NULL) {
    if (strcmp(f->fileName, "..") == 0) {
      printf("<br><a href=""/cgi-bin/fileview.cgi"
		"?submitSearch=FileSelect"
		"&Key=%s"
		"&CurrentDirectory=%s"
		"&>%s</a>\n",
	   ".",
	   parentPath,
	   f->fileName);
    } else {
      printf("<br><a href=""/cgi-bin/fileview.cgi"
		"?submitSearch=FileSelect"
		"&Key=%s"
		"&CurrentDirectory=%s"
		"&>%s</a>\n",
	   f->fileName,
	   path,
	   f->fileName);
    }
    free(f);
  }
  html_end();
  LST_Destroy(&l);
}