void LightmapsPacker::ParseSpriteDescriptors() { FileList * fileList = new FileList(outputDir); char8 buf[512]; uint32 readSize; int32 itemsCount = fileList->GetCount(); for(int32 i = 0; i < itemsCount; ++i) { const FilePath & filePath = fileList->GetPathname(i); if(fileList->IsDirectory(i) || !filePath.IsEqualToExtension(".txt")) { continue; } LightmapAtlasingData data; data.meshInstanceName = filePath.GetBasename(); File * file = File::Create(filePath, File::OPEN | File::READ); file->ReadLine(buf, sizeof(buf)); //textures count readSize = file->ReadLine(buf, sizeof(buf)); //texture name FilePath originalTextureName = outputDir + String(buf, readSize); data.textureName = originalTextureName; file->ReadLine(buf, sizeof(buf)); //image size file->ReadLine(buf, sizeof(buf)); //frames count file->ReadLine(buf, sizeof(buf)); //frame rect int32 x, y, dx, dy, unused0, unused1, unused2; sscanf(buf, "%d %d %d %d %d %d %d", &x, &y, &dx, &dy, &unused0, &unused1, &unused2); dx++;//cause TexturePacker::ReduceRectToOriginalSize removed one pixel by default dy++; Vector2 textureSize = GetTextureSize(originalTextureName); data.uvOffset = Vector2((float32)x/textureSize.x, (float32)y/textureSize.y); data.uvScale = Vector2((float32)dx/textureSize.x, (float32)dy/textureSize.y); file->Release(); atlasingData.push_back(data); FileSystem::Instance()->DeleteFile(filePath); } fileList->Release(); }
void OpenWrite(ofstream& s, const char *name, FileList& flist) { // post condition: file is successfully opened iff // name is added to flist (even if exception is thrown). // We do the AddFile first, since that can conceivably fail. flist.AddFile(name); s.open(name, ios::out); if (!s) { flist.RemoveLast(); FileError("write open failed"); } }
void TestFileList::filterFiles4() { FileList list; QStringList filters; filters << "dir1/"; list.AddExcludeList(filters); list.AddDirectory(QString(SRCDIR) + "/../data/files", true); QStringList files = list.GetFileList(); QCOMPARE(files.size(), 8); QDir dir(QString(SRCDIR) + "/../data/files"); QString base = dir.canonicalPath(); QVERIFY(! files.contains(base + "/dir1/foo1.cpp")); QVERIFY(! files.contains(base + "/dir1/dir11/foo11.cpp")); }
PresetList::PresetList() : Wt::Ext::TableView() { File presetdir(org::esb::config::Config::get("preset.path")); if (presetdir.exists()) { FileList files = presetdir.listFiles(); std::list<std::list<std::string> > data; FileList::iterator file_it = files.begin(); for (; file_it != files.end(); file_it++) { org::esb::hive::PresetReader reader((*file_it)->getPath()); LOGDEBUG((*file_it)->getPath()); std::list<std::string> line; line.push_back((*file_it)->getFileName()); line.push_back(reader.getPreset()["name"]); //line.push_back(reader.getPreset()["id"]); data.push_back(line); } setModel(new PresetListTableModel(data)); setAlternatingRowColors(true); resizeColumnsToContents(true); setColumnHidden(0, true); setHighlightMouseOver(true); setSelectionBehavior(Wt::SelectRows); setSelectionMode(Wt::SingleSelection); setColumnWidth(0, 50); setAutoExpandColumn(1); itemSelectionChanged().connect(SLOT(this, PresetList::selectionChanged)); setTopToolBar(new Wt::Ext::ToolBar()); create_button = topToolBar()->addButton("Create a new Preset"); create_button->setIcon("icons/add-icon.png"); topToolBar()->addSeparator(); edit_button = topToolBar()->addButton("Edit selected Preset"); edit_button->setIcon("icons/edit-icon.png"); //topToolBar()->addSeparator(); //delete_button = topToolBar()->addButton("Delete selected Preset"); //delete_button->setIcon("icons/encoding-project-remove-icon.png"); create_button->setEnabled(true); edit_button->setEnabled(false); //delete_button->setEnabled(false); create_button->clicked().connect(SLOT(this, PresetList::createPreset)); edit_button->clicked().connect(SLOT(this, PresetList::editPreset)); //delete_button->clicked().connect(SLOT(this, PresetList::deletePreset)); } else { LOGERROR("Preset Directory does not exist! " << presetdir.getPath()); } }
bool DataTransfer::hasFileOfType(const String& type) const { if (!canReadTypes()) return false; FileList* fileList = files(); if (fileList->isEmpty()) return false; for (unsigned f = 0; f < fileList->length(); f++) { if (equalIgnoringCase(fileList->item(f)->type(), type)) return true; } return false; }
void output(const FileList& flist) { for (BOOST_AUTO(iter, flist.begin()); iter != flist.end(); ++iter) { BOOST_AUTO(&fmeta, iter->second); std::vector<char> buffer; std::cout << "name : " << GetFileName(fmeta.mName, buffer) << "\n, " << "meta : {" << fmeta.mMeta << "}, \n" << "offset: " << fmeta.mOffset << ", \n" << "fsize : " << fmeta.mFileSize << ", \n" << "wbsize: " << fmeta.mWriteBSize << "\n" << std::endl; } }
void deduplicate(const File &inputGallery, const File &outputGallery, const float threshold) { qDebug("Deduplicating %s to %s with a score threshold of %f", qPrintable(inputGallery.flat()), qPrintable(outputGallery.flat()), threshold); if (distance.isNull()) qFatal("Null distance."); QScopedPointer<Gallery> i; FileList inputFiles; retrieveOrEnroll(inputGallery, i, inputFiles); TemplateList t = i->read(); Output *o = Output::make(QString("buffer.tail[selfSimilar,threshold=%1,atLeast=0]").arg(QString::number(threshold)),inputFiles,inputFiles); // Compare to global tail output distance->compare(t,t,o); delete o; QString buffer(Globals->buffer); QStringList tail = buffer.split("\n"); // Remove header tail.removeFirst(); QStringList toRemove; foreach(const QString &s, tail) toRemove.append(s.split(',').at(1)); QSet<QString> duplicates = QSet<QString>::fromList(toRemove); QStringList fileNames = inputFiles.names(); QList<int> indices; foreach(const QString &d, duplicates) indices.append(fileNames.indexOf(d)); std::sort(indices.begin(),indices.end(),std::greater<float>()); qDebug("\n%d duplicates removed.", indices.size()); for (int i=0; i<indices.size(); i++) inputFiles.removeAt(indices[i]); QScopedPointer<Gallery> og(Gallery::make(outputGallery)); og->writeBlock(inputFiles); }
FileList* DataTransfer::files() const { FileList* files = FileList::create(); if (!canReadData()) return files; for (size_t i = 0; i < m_dataObject->length(); ++i) { if (m_dataObject->item(i)->kind() == DataObjectItem::FileKind) { Blob* blob = m_dataObject->item(i)->getAsFile(); if (blob && blob->isFile()) files->append(toFile(blob)); } } return files; }
// ------------------------------------------------------------------------------------------------ // // void CUI_Loadscreen::enter(void) { need_refresh = 1; is_loading = 0; cur_state = STATE_LOAD; FileList *fl; DirList *dl; fl = (FileList *)UI->get_element(0); dl = (DirList *)UI->get_element(1); dl->OnChange(); fl->OnChange(); if (song->filename[0] && song->filename[0]!=' ') strcpy(load_filename, (const char *)song->filename); // fl->set_cursor(load_filename); fl->setCursor(fl->findItem(load_filename)); }
FileList Bitmunk::getModulePaths() { FileList rval; Config cfg = getConfig()["node"]; ConfigIterator mpi = cfg["modulePath"].getIterator(); while(mpi->hasNext()) { const char* path = mpi->next()->getString(); FileList pathList = File::parsePath(path); rval->concat(*pathList); } return rval; }
String FileInputType::defaultToolTip() const { FileList* fileList = m_fileList.get(); unsigned listSize = fileList->length(); if (!listSize) return fileButtonNoFileSelectedLabel(); StringBuilder names; for (size_t i = 0; i < listSize; ++i) { names.append(fileList->item(i)->fileName()); if (i != listSize - 1) names.append('\n'); } return names.toString(); }
void GenFileList( const string& path ) { const string CURR_PATH = "."; const string PARENT_PATH = ".."; WIN32_FIND_DATA fd; string cur_file; string szFullPath(path + "/*"); HANDLE h = FindFirstFile( szFullPath.c_str(), &fd ); if ( h != INVALID_HANDLE_VALUE ) { BOOL bMoreFile = 1; while ( bMoreFile ) { if ( CURR_PATH != fd.cFileName && PARENT_PATH != fd.cFileName ) { cur_file = path + "/" + fd.cFileName; if ( fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { if ( fd.cFileName[0] != '.' ) GenFileList(cur_file); } else { backslash_to_slash(cur_file); cur_file = cur_file.substr(cur_file.find("sound"), cur_file.length()); g_file_list.push_back(cur_file); } } bMoreFile = FindNextFile( h, &fd ); } FindClose(h); } }
static v8::Handle<v8::Value> itemCallback(const v8::Arguments& args) { INC_STATS("DOM.FileList.item"); FileList* imp = V8FileList::toNative(args.Holder()); ExceptionCode ec = 0; { int index = toInt32(args[0]); if (UNLIKELY(index < 0)) { ec = INDEX_SIZE_ERR; goto fail; } return toV8(imp->item(index)); } fail: V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); }
/** * Lists the contents of the directory denoted by this File. If the current * File doesn't point to a directory or does not exist, an exception is thrown. * * @param result matching names will be put here * @param filter optional filter filter which can be used to filter filenames. * @return the number of items put into the result */ size_t File::listDirectory(FileList &result, FileFilter *filter) const { if (!exists()) throw std::logic_error("Cannot list a non-existing directory"); if (!isDirectory()) throw std::logic_error("Cannot list file which isn't a directory"); if (!canRead()) throw std::logic_error(std::string("No read access for directory ") + fullname); DIR *dir = opendir(fullname.c_str()); if (dir == NULL) { throw std::logic_error("opendir() failed for a directory"); } size_t numItems = 0; struct dirent *pEntry; pEntry = readdir(dir); while (pEntry) { // do not include "." and ".." in the list if (strcmp(pEntry->d_name, ".") && strcmp(pEntry->d_name, "..")) { File f(*this, pEntry->d_name); if (!filter || (*filter)(f)) { result.push_back(std::move(f)); ++numItems; } } pEntry = readdir(dir); } closedir(dir); return numItems; }
JSValue* jsFileListPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSFileList::s_info)) return throwError(exec, TypeError); JSFileList* castedThisObj = static_cast<JSFileList*>(thisValue); FileList* imp = static_cast<FileList*>(castedThisObj->impl()); int index = args[0]->toInt32(exec); if (index < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->item(index))); return result; }
static ibool loaddirectories(const char *filename,FileList& fileList) /**************************************************************************** * * Function: loaddirectories * Parameters: filename - Name of directories to look for * fileList - Place to store the filenames * Returns: True on success, false on memory error * * Description: Loads a list of all the directories from the current * directory into the specified name list. * ****************************************************************************/ { PM_findData findData; void *hfile; ibool valid; valid = (hfile = PM_findFirstFile(filename,&findData)) != NULL; while (valid) { if ((findData.attrib & PM_FILE_DIRECTORY) && findData.name[0] != '.') { fileList.add(new TCDynStr(findData.name)); if (MV_lowMemory()) return false; } valid = PM_findNextFile(hfile,&findData); } if (hfile) PM_findClose(hfile); return true; }
void write_hash_file(const char* name, int fileCount, char** files) { int file = open(name, O_WRONLY | O_TRUNC | O_CREAT); if (file < 0) { fprintf(stderr, "%s: Could not write hash file \"%s\": %s\n", kProgramName, name, strerror(errno)); return; } write(file, "HASH", 4); write(file, &fileCount, sizeof(int)); for (int i = 0; i < fileCount; i++) { int length = strlen(files[i]); write(file, &length, sizeof(int)); write(file, files[i], length + 1); } fileCount = gFiles.size(); write(file, &fileCount, sizeof(int)); for (int i = 0; i < fileCount; i++) { file_entry& entry = gFiles[i]; write(file, entry.hash, SHA_DIGEST_LENGTH); write(file, &entry.node, sizeof(ino_t)); int length = entry.path.size(); write(file, &length, sizeof(int)); write(file, entry.path.c_str(), length + 1); } close(file); }
bool BookManager::importDirectory( const char* directory, int threshold) { // 棋譜の列挙 FileList fileList; fileList.enumerate(directory, "csa"); int count = 0; while (!fileList.isEnd()) { const std::string& path = fileList.pop(); count++; Log::message << count << '\t' << path << '\n'; if (!importFile(path.c_str(), threshold)) { return false; } } return true; }
bool FileSystem::take(FileNode* node) { pthread_mutex_lock(&fmap_mux); int ret = file_map.erase(node->pathname); pthread_mutex_unlock(&fmap_mux); if (ret == 0) return false; FileList* files = &(node->parent->children); FileList::iterator it = ::find(files->begin(), files->end(), node); if (it != files->end()) { files->erase(it); return true; } return false; }
String FileInputType::defaultToolTip(const InputTypeView&) const { FileList* fileList = m_fileList.get(); unsigned listSize = fileList->length(); if (!listSize) { return locale().queryString( WebLocalizedString::FileButtonNoFileSelectedLabel); } StringBuilder names; for (size_t i = 0; i < listSize; ++i) { names.append(fileList->item(i)->name()); if (i != listSize - 1) names.append('\n'); } return names.toString(); }
void filelist_onEnter(UserInterfaceElement *b) { if(ztPlayer->playing) { UIP_RUSure->str = " You crazy?"; popup_window(UIP_RUSure); return; } UIP_RUSure->str = " Load file?"; UIP_RUSure->OnYes = (VFunc)do_load; FileList *f = (FileList *)b; strcpy(load_filename,f->getCurrentItem()); if (file_changed) popup_window(UIP_RUSure); else popup_window(UIP_LoadMsg); }
void TestFileList::addPathList() { // Accepted extensions: *.cpp, *.cxx, *.cc, *.c, *.c++, *.txx, *.tpp" QStringList paths; paths << QString(SRCDIR) + "/../data/files/foo1.cpp"; paths << QString(SRCDIR) + "/../data/files/foo2.cxx"; paths << QString(SRCDIR) + "/../data/files/foo3.cc"; paths << QString(SRCDIR) + "/../data/files/foo4.c"; paths << QString(SRCDIR) + "/../data/files/foo5.c++"; paths << QString(SRCDIR) + "/../data/files/foo6.txx"; paths << QString(SRCDIR) + "/../data/files/foo7.tpp"; FileList list; list.AddPathList(paths); QStringList files = list.GetFileList(); QCOMPARE(files.size(), 7); }
void Update::makeFileList(FileList& fileListMap, const char *fileList) { char fileName[RES_PATH_MAX + 1]; char hashSHA1[HASH_STRING_MAX + 1]; int fileSize; while(*fileList) { int nRet = sscanf(fileList, "%[^=]=%[^,],%d", fileName, hashSHA1, &fileSize); if(nRet == 3) { fileListMap.insert(pair<string, FileInfo>(fileName, FileInfo(fileName, hashSHA1, fileSize))); } if((fileList = strchr(fileList, '\n'))) { fileList++; } else { break; } } }
void SlideEventHandler::previousSlide() { if (_switch->getNumChildren()==0) return; if (_fileList.size()>0) { if (_activeSlide==0) _activeSlide = _fileList.size()/2-1; else --_activeSlide; osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length); if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get()); } else { if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1; else --_activeSlide; _switch->setSingleChildOn(_activeSlide); } }
FileList findFiles(string dir, string filemask) { FileList res; DIR* td=opendir(dir.c_str()); dirent*p; if (!td) return res; while (p=readdir(td)) { string dirname=p->d_name; if (!isDir(dirname)&&matchMask(dirname, filemask)) res.push_back(dir+'\\'+dirname); } closedir(td); return res; }
// used for resolving case-insensative paths to case-sensative ones // when appropriate IsCaseSensative() = true bool PlatformNormalize(std::string &normpath, const std::string &path, const std::string root) { if (!FileList::IsCaseSensative()) // windows simply returns identity { // should only get hit on windows if (root[root.length()-1] != '\\') { normpath = root + "\\" + path; } else { normpath = root + path; } return true; } // else it's a *nix system - normalize it to / instead of \ - FileList curdir; normpath = root; // break path down into it's componants std::vector<std::string> parts; Expand(path, '/', parts); bool found; for (size_t i = 0; i < parts.size(); i++) { curdir.GetList(normpath); found = false; for (size_t j = 0; j < curdir.Size(); j++) { if (strLower(std::string(curdir[j])) == strLower(std::string(parts[i]))) { normpath += std::string("/") + curdir[j]; found = true; break; } } if (!found) return false; //yikes curdir.Clear(); } return true; }
void SubjectViewer::setFiles(const FileList &files) { if (files.isEmpty()) return; currentIndex = 0; this->files = files; TemplateViewer::setFile(this->files[currentIndex]); }
void ImportProject::getResultsFiles () { string rPath = uploadName + SLASH + "results"; FileList resFileList ( rPath, "", "", false ); for ( FileList::size_type i = 0 ; i < resFileList.size () ; i++ ) { string f = resFileList [i]; if ( isSuffix ( f, ".xml" ) ) { resFiles.push_back ( f ); if ( Version::instance ().isNewerVersion ( getVersionFromPPXMLFile ( rPath + SLASH + f ) ) ) { genUnlinkDirectory ( uploadName ); throw runtime_error ( "The imported project contains searches from a newer version than you have installed." ); } } if ( isSuffix ( f, ".disc.txt" ) ) discFiles.push_back ( f ); } parseResultsFiles (); }
void process_file(const char* path) { struct stat stat; if (::lstat(path, &stat) != 0) { fprintf(stderr, "Could not stat file \"%s\": %s\n", path, strerror(errno)); return; } if (S_ISDIR(stat.st_mode)) { process_directory(path); return; } if (S_ISLNK(stat.st_mode)) return; int file = open(path, O_RDONLY); if (file < 0) { fprintf(stderr, "Could not open file \"%s\": %s\n", path, strerror(errno)); return; } status_t status = gSHA.Process(file); if (status != B_OK) { fprintf(stderr, "Computing SHA failed \"%s\": %s\n", path, strerror(status)); return; } file_entry entry; memcpy(entry.hash, gSHA.Digest(), SHA_DIGEST_LENGTH); entry.node = stat.st_ino; entry.path = path; //printf("%s %s\n", entry.HashString().c_str(), path); gFiles.push_back(entry); static bigtime_t sLastUpdate = -1; if (system_time() - sLastUpdate > 500000) { printf("%ld files scanned\33[1A\n", gFiles.size()); sLastUpdate = system_time(); } }
void PresetList::refresh() { File presetdir(org::esb::config::Config::get("preset.path")); if (presetdir.exists()) { FileList files = presetdir.listFiles(); std::list<std::list<std::string> > data; FileList::iterator file_it = files.begin(); for (; file_it != files.end(); file_it++) { org::esb::hive::PresetReader reader((*file_it)->getPath()); LOGDEBUG((*file_it)->getPath()); std::list<std::string> line; line.push_back((*file_it)->getFileName()); line.push_back(reader.getPreset()["name"]); data.push_back(line); } static_cast<PresetListTableModel*>(model())->setModelData(data); } }