bool GalleryUtil::LoadDirectory(ThumbList& itemList, const QString& dir, const GalleryFilter& flt, bool recurse, ThumbHash *itemHash, ThumbGenerator* thumbGen) { QString blah = dir; QDir d(blah); QString currDir = d.absolutePath(); QStringList splitFD; bool isGallery; QFileInfoList gList = d.entryInfoList(QStringList("serial*.dat"), QDir::Files); isGallery = (gList.count() != 0); // Create .thumbcache dir if neccesary if (thumbGen) thumbGen->getThumbcacheDir(currDir); QFileInfoList list = d.entryInfoList(GetMediaFilter(), QDir::Files | QDir::AllDirs, (QDir::SortFlag)flt.getSort()); if (list.isEmpty()) return false; QFileInfoList::const_iterator it = list.begin(); const QFileInfo *fi; if (thumbGen) { thumbGen->cancel(); thumbGen->setDirectory(currDir, isGallery); } if (!flt.getDirFilter().isEmpty()) { splitFD = flt.getDirFilter().split(":"); } while (it != list.end()) { fi = &(*it); ++it; if (fi->fileName() == "." || fi->fileName() == "..") continue; // remove these already-resized pictures. if (isGallery && ( (fi->fileName().indexOf(".thumb.") > 0) || (fi->fileName().indexOf(".sized.") > 0) || (fi->fileName().indexOf(".highlight.") > 0))) continue; // skip filtered directory if (fi->isDir() && !splitFD.filter(fi->fileName(), Qt::CaseInsensitive).isEmpty()) continue; if (fi->isDir() && recurse) { LoadDirectory(itemList, QDir::cleanPath(fi->absoluteFilePath()), flt, true, itemHash, thumbGen); } else { if ((GalleryUtil::IsImage(fi->absoluteFilePath()) && flt.getTypeFilter() == kTypeFilterMoviesOnly) || (GalleryUtil::IsMovie(fi->absoluteFilePath()) && flt.getTypeFilter() == kTypeFilterImagesOnly)) continue; ThumbItem *item = new ThumbItem(fi->fileName(), QDir::cleanPath(fi->absoluteFilePath()), fi->isDir()); itemList.append(item); if (itemHash) itemHash->insert(item->GetName(), item); if (thumbGen) thumbGen->addFile(item->GetName()); } } return isGallery; }
int main( int argc, char** argv ) { Init(); std::vector<BMP*> images = LoadDirectory( "InputImages/" ); // Exit the application is there is not 16 images provided if( images.size() != static_cast<unsigned int>( 16 ) ) { Log( "There needs to be exactly 16 images in the InputImages directory to process. Exiting" ); return -1; } int repeatAttempts = 0; for( int NUM_IMAGES = 0; NUM_IMAGES < 1; NUM_IMAGES++ ) { std::random_shuffle( images.begin(), images.end() ); int suffix = std::rand(); std::stringstream ss; BMP* resultImage = CombineBitmaps( images ); ss << "OutputImages/SolutionBefore_" << suffix << ".bmp"; Log( "Outputting before image:\t" + ss.str( )); resultImage->WriteToFile( ss.str().c_str() ); ss.str(""); delete resultImage; std::vector<int> noLeftMatches; Log( "Finding the left edges"); // Move all of the pieces with no left edge onto the front of the array for( unsigned int i = 0; i < images.size(); i++ ) { float lowestFactor = 1.0f; for( unsigned int j = 0; j < images.size(); j++ ) { if( i == j ) { continue; } float value = EdgeFactor( *images[i], *images[j], vec2i( -1, 0 ) ); if( value < lowestFactor ) { lowestFactor = value; } } // This constant could be dynamically generated to make the application more accurate if( lowestFactor > 0.08f ) { noLeftMatches.push_back( i ); } } // Move each left piece to the left of the image Log( "Moving the left edges to the left" ); for( unsigned int i = 0; i < noLeftMatches.size(); i++ ) { BMP* tmp = NULL; int pos = i*4; tmp = images[pos]; images[pos] = images[noLeftMatches[i]]; images[noLeftMatches[i]] = tmp; } // Go over each piece building the rows Log( "Doing the row filtering" ); for( unsigned int i = 0; i < images.size()-1; i++ ) { if( i%4==3 ) { continue; } int lowestIndex = i+1; float lowestValue = 1.0; for( unsigned int j = i+1; j < images.size(); j++ ) { float value = EdgeFactor( *images[i], *images[j], vec2i( 1, 0 ) ); if( value < lowestValue ) { lowestValue = value; lowestIndex = j; } } // Swap the lowest index BMP* tmp = images[i+1]; images[i+1] = images[lowestIndex]; images[lowestIndex] = tmp; } // Swap the rows that match // Find the row with the worst top matches Log( "Finding the top row" ); int worstTopRow = 0; float worstTopValue = 0.0f; for( unsigned int i = 0; i < 4; i++ ) { for( unsigned int j = 0; j < 4; j++ ) { if(i == j) { continue; } float value = EdgeFactor( *images[i*4], *images[j*4], vec2i( 0, -1 ) ); if( value > worstTopValue ) { worstTopValue = value; worstTopRow = i; } } } // Move the top row to the top Log( "Moving the top row to the top" ); for( unsigned int i = 0; i < 4; i++ ) { BMP* tmp = images[i]; images[i] = images[(worstTopRow*4)+i]; images[(worstTopRow*4)+i] = tmp; } // Sort the rows Log( "Sorting the rows" ); for( unsigned int i = 0; i <3; i++ ) { int rowPos = 0; float bestRowValue = 1.0f; for( unsigned int j = i; j < 4; j++ ) { if( i==j ) { continue; } float value = EdgeFactor( *images[4*i], *images[4*j], vec2i( 0, 1 ) ); if( value < bestRowValue ) { rowPos = j*4; bestRowValue = value; } } // Swap the rows for( unsigned int j = 0; j < 4; j++ ) { BMP* tmp = images[(i*4)+4+j]; images[(i*4)+4+j] = images[rowPos+j]; images[rowPos+j] = tmp; } } // Final check to make sure that the solution is correct Log( "Doing final check to make sure solution is correct..." ); bool pass = true; float passThreshold = 0.2f; for( unsigned int i = 0; i < images.size()-1; i++ ) { // Only check the bottom tile for right most tiles if( i%4==3 ) { if( EdgeFactor( *images[i], *images[i+4], vec2i( 0, 1 ) ) > passThreshold ) { pass = false; break; } } else if( i < 11 ) // Check the bottom and right neighbor for middle rows { if( EdgeFactor( *images[i], *images[i+4], vec2i( 0, 1 ) ) > passThreshold || EdgeFactor( *images[i], *images[i+1], vec2i( 1, 0 ) ) > passThreshold ) { pass = false; break; } } else // Check the right neighbor only on the bottom row { if( EdgeFactor( *images[i], *images[i+1], vec2i( 1, 0 ) ) > passThreshold ) { pass = false; break; } } } // If the image did not pass the final check discard the image and repeat the process if( !pass ) { NUM_IMAGES--; repeatAttempts++; if( repeatAttempts > 10 ) { Log( "Allowing incorrect solution to be outputted because of multiple reattempts. Finishing execution of application" ); NUM_IMAGES = 1000000; } else { Log( "*** Final solution is incorrect. Repeating process" ); continue; } } else { repeatAttempts = 0; ss << "Final solution is correct, used " << edgeComps << " unique edge to edge comparisons to complete the solution. The tile map has " << values.size() << " saved combinations. Using the stored values saved " << savedComps << " edge to edge comparisons!"; edgeComps = 0; savedComps = 0; Log( ss.str() ); ss.str(""); } ss << "OutputImages/FinalSolution_" << suffix << ".bmp"; Log( "Saving final solution into OutputImages:\t" + ss.str()); resultImage = CombineBitmaps( images ); resultImage->WriteToFile( ss.str().c_str() ); ss.str(""); delete resultImage; } return 0; }
static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_len, HashTable *parent_ht) { DWORD keys, values, max_key, max_name, max_value; int ret = 0; HashTable *ht = NULL; if (RegQueryInfoKey(key, NULL, NULL, NULL, &keys, &max_key, NULL, &values, &max_name, &max_value, NULL, NULL) == ERROR_SUCCESS) { if (values) { DWORD i; char *name = (char*)emalloc(max_name+1); char *value = (char*)emalloc(max_value+1); DWORD name_len, type, value_len; for (i = 0; i < values; i++) { name_len = max_name+1; value_len = max_value+1; memset(name, '\0', max_name+1); memset(value, '\0', max_value+1); if (RegEnumValue(key, i, name, &name_len, NULL, &type, value, &value_len) == ERROR_SUCCESS) { if ((type == REG_SZ) || (type == REG_EXPAND_SZ)) { zval data; if (!ht) { ht = (HashTable*)malloc(sizeof(HashTable)); if (!ht) { return ret; } zend_hash_init(ht, 0, NULL, ZVAL_INTERNAL_PTR_DTOR, 1); } ZVAL_PSTRINGL(&data, value, value_len-1); zend_hash_str_update(ht, name, name_len, &data); } } } if (ht) { if (parent_ht) { zend_string *index; zend_ulong num; zval *tmpdata; ZEND_HASH_FOREACH_KEY_VAL(parent_ht, num, index, tmpdata) { zend_hash_add(ht, index, tmpdata); } ZEND_HASH_FOREACH_END(); } zend_hash_str_update_mem(directories, path, path_len, ht, sizeof(HashTable)); ret = 1; } efree(name); efree(value); } if (ht == NULL) { ht = parent_ht; } if (keys) { DWORD i; char *name = (char*)emalloc(max_key+1); char *new_path = (char*)emalloc(path_len+max_key+2); DWORD name_len; FILETIME t; HKEY subkey; for (i = 0; i < keys; i++) { name_len = max_key+1; if (RegEnumKeyEx(key, i, name, &name_len, NULL, NULL, NULL, &t) == ERROR_SUCCESS) { if (RegOpenKeyEx(key, name, 0, KEY_READ, &subkey) == ERROR_SUCCESS) { if (path_len) { memcpy(new_path, path, path_len); new_path[path_len] = '/'; memcpy(new_path+path_len+1, name, name_len+1); zend_str_tolower(new_path, path_len+name_len+1); name_len += path_len+1; } else { memcpy(new_path, name, name_len+1); zend_str_tolower(new_path, name_len); } if (LoadDirectory(directories, subkey, new_path, name_len, ht)) { ret = 1; } RegCloseKey(subkey); } } } efree(new_path); efree(name); } }
void MainUI::OpenDirs(QStringList dirs){ //Now open the dirs if(dirs.isEmpty()){ dirs << QDir::homePath(); } QStringList invalid; for(int i=0; i<dirs.length(); i++){ if(dirs[i].simplified().isEmpty()){ continue; } //Open this directory in a viewer if(dirs[i].endsWith("/")){ dirs[i].chop(1); } if(!QFile::exists(dirs[i])){ invalid << dirs[i]; continue; } if(DEBUG){ qDebug() << "Open Directory:" << dirs[i]; } ///Get a new Unique ID int id = 0; for(int j=0; j<DWLIST.length(); j++){ if(DWLIST[j]->id().section("-",1,1).toInt() >= id){ id = DWLIST[j]->id().section("-",1,1).toInt()+1; } } //Create the new DirWidget DirWidget *DW = new DirWidget("DW-"+QString::number(id), this); DW->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->BrowserLayout->addWidget(DW); DWLIST << DW; //Connect the signals/slots for it connect(DW, SIGNAL(OpenDirectories(QStringList)), this, SLOT(OpenDirs(QStringList)) ); connect(DW, SIGNAL(LoadDirectory(QString, QString)), worker, SLOT(GetDirData(QString, QString)) ); connect(DW, SIGNAL(findSnaps(QString, QString)), worker, SLOT(GetSnapshotData(QString, QString)) ); connect(DW, SIGNAL(PlayFiles(LFileInfoList)), this, SLOT(OpenPlayer(LFileInfoList)) ); connect(DW, SIGNAL(ViewFiles(LFileInfoList)), this, SLOT(OpenImages(LFileInfoList)) ); connect(DW, SIGNAL(LaunchTerminal(QString)), this, SLOT(OpenTerminal(QString)) ); connect(DW, SIGNAL(CutFiles(QStringList)), this, SLOT(CutFiles(QStringList)) ); connect(DW, SIGNAL(CopyFiles(QStringList)), this, SLOT(CopyFiles(QStringList)) ); connect(DW, SIGNAL(FavoriteFiles(QStringList)), this, SLOT(FavoriteFiles(QStringList)) ); connect(DW, SIGNAL(RenameFiles(QStringList)), this, SLOT(RenameFiles(QStringList)) ); connect(DW, SIGNAL(RemoveFiles(QStringList)), this, SLOT(RemoveFiles(QStringList)) ); connect(DW, SIGNAL(PasteFiles(QString,QStringList)), this, SLOT(PasteFiles(QString, QStringList)) ); connect(DW, SIGNAL(CloseBrowser(QString)), this, SLOT(CloseBrowser(QString)) ); //Now create the tab for this if(radio_view_tabs->isChecked()){ int index = tabBar->addTab( LXDG::findIcon("folder-open",""), dirs[i].section("/",-1) ); tabBar->setTabWhatsThis( index, "DW-"+QString::number(id) ); tabBar->setCurrentIndex(index); }else{ //Just make sure the browser tab is visible bool found = false; for(int i=0; i<tabBar->count() && !found; i++){ if(tabBar->tabWhatsThis(i)=="browser"){ tabBar->setCurrentIndex(i); found=true; } } if(!found){ //Need to create the generic Browser tab int index = tabBar->addTab( LXDG::findIcon("folder-open",""), "Browser" ); tabBar->setTabWhatsThis( index, "browser" ); tabBar->setCurrentIndex(index); } } //Initialize the widget with the proper settings DW->setShowDetails(radio_view_details->isChecked()); DW->setShowSidebar(ui->actionShow_Action_Buttons->isChecked()); QList<DirWidget::DETAILTYPES> details; details <<DirWidget::NAME << DirWidget::SIZE << DirWidget::TYPE << DirWidget::DATEMOD; DW->setDetails(details); //Which details to show and in which order (L->R) DW->setShowThumbnails(ui->actionShow_Thumbnails->isChecked()); DW->setThumbnailSize(settings->value("iconsize", 32).toInt()); DW->setDirCompleter(dirCompleter); DW->setShowCloseButton(!radio_view_tabs->isChecked()); //Now load the directory DW->ChangeDir(dirs[i]); //kick off loading the directory info } //Update visibilities tabChanged(tabBar->currentIndex()); tabBar->setVisible( tabBar->count() > 1 ); if(!invalid.isEmpty()){ QMessageBox::warning(this, tr("Invalid Directories"), tr("The following directories are invalid and could not be opened:")+"\n"+invalid.join(", ") ); } //Double check that there is at least 1 dir loaded //qDebug() << "OpenDirs:" << DWLIST.length() << dirs << invalid << tabBar->currentIndex(); if(DWLIST.isEmpty()){ OpenDirs(QStringList()); } }
FBDirectory::FBDirectory(const char* name) { dir = nil; LoadDirectory(name); }
void DirWidget::on_actionHome_triggered(){ stopload = true; //just in case it is still loading emit LoadDirectory(ID, QDir::homePath()); }
/* * Validates the signatures of a HLL debug info block, determining * the length if necessary. */ static dip_status FoundHLLSign( imp_image_handle *ii, unsigned long off, unsigned long size ) { dip_status rc; hll_trailer hdr; unsigned long off_dirent, off_trailer; /* read the header. */ rc = DCReadAt( ii->sym_file, &hdr, sizeof( hdr ), off ); if( rc & DS_ERR) { return rc; } if( !IsHllSignature( &hdr ) ) { return DS_FAIL; } /* * Read the directory info - both to verify it and to find the trailer. */ off_dirent = off + hdr.offset; if( !memcmp( hdr.sig, HLL_NB04, HLL_SIG_SIZE ) ) { hll_dirinfo dir_hdr; rc = DCReadAt( ii->sym_file, &dir_hdr, sizeof( dir_hdr ), off_dirent ); if( rc & DS_ERR) { return rc; } if( dir_hdr.cbDirHeader != sizeof( hll_dirinfo ) || dir_hdr.cbDirEntry != sizeof( hll_dir_entry ) ) { return DS_FAIL; } ii->dir_count = dir_hdr.cDir; off_dirent += sizeof( dir_hdr ); off_trailer = off_dirent + sizeof( hll_dir_entry ) * dir_hdr.cDir; } else { /* Old CV3 directory. */ cv3_dirinfo dir_hdr; rc = DCReadAt( ii->sym_file, &dir_hdr, sizeof( dir_hdr ), off_dirent ); if( rc & DS_ERR) { return rc; } ii->dir_count = dir_hdr.cDir; off_dirent += sizeof( dir_hdr ); off_trailer = off_dirent + sizeof( cv3_dir_entry ) * dir_hdr.cDir; } /* is the trailer following the directory? It usually is with wlink. */ rc = DCReadAt( ii->sym_file, &hdr, sizeof( hdr ), off_trailer ); if( rc & DS_ERR) { return rc; } if( !IsHllSignature( &hdr ) ) { /* * No it isn't, seek from the end (off + size). * Adjust the length first. */ long cur; unsigned overlap = 0; cur = DCSeek( ii->sym_file, 0, DIG_END ); if( cur > size + off && size + off > size ) { cur = off + size; } hdr.sig[0] = 0; do { char buf[1024 + sizeof( hdr )]; unsigned to_read; char *ptr; /* read block */ to_read = 1024 + overlap; cur -= 1024; if( cur < off_trailer ) { to_read += off_trailer - cur; cur = off_trailer; } if( to_read < sizeof( hdr) ) { return DS_FAIL; } rc = DCReadAt( ii->sym_file, buf, to_read, cur ); if( rc & DS_ERR ) { return rc; } /* search it */ for( ptr = &buf[to_read - sizeof( hdr )]; ptr >= &buf[0]; ptr--) { if( IsHllSignature(ptr) ) { off_trailer = cur + ptr - &buf[0]; hdr = *(hll_trailer *)ptr; break; } } /* next */ overlap = sizeof( hdr ); } while( hdr.sig[0] == 0 ); } /* * Validate the trailer offset (=size). */ if( off_trailer == off || hdr.offset != off_trailer - off + sizeof( hdr ) ) { return( DS_FAIL ); } /* * We're good. */ ii->bias = off; ii->size = off_trailer - off + sizeof( hdr ); if ( !memcmp( hdr.sig, HLL_NB04, HLL_SIG_SIZE ) ) { ii->format_lvl = HLL_LVL_NB04; } else if ( !memcmp( hdr.sig, HLL_NB02, HLL_SIG_SIZE ) ) { ii->format_lvl = HLL_LVL_NB02; } else if( !memcmp( hdr.sig, HLL_NB00, HLL_SIG_SIZE ) ) { ii->format_lvl = ii->is_32bit ? HLL_LVL_NB00_32BIT : HLL_LVL_NB00; } else { hllConfused(); } /* * Since we already know where the directory is, we load it here. */ rc = LoadDirectory( ii, off_dirent ); return( rc ); }
void DirWidget::ChangeDir(QString dirpath){ stopload = true; //just in case it is still loading emit LoadDirectory(ID, dirpath); }
void DirWidget::refresh(){ if(!CDIR.isEmpty() && ~ID.isEmpty()){ stopload = true; //just in case it is still loading emit LoadDirectory(ID, CDIR); } }
void Eluna::StartEluna(bool restart) { if (restart) { sHookMgr->OnEngineRestart(); TC_LOG_INFO(LOG_FILTER_GENERAL, "Eluna::Restarting Lua Engine"); if (LuaState) { // Unregisters and stops all timed events LuaEventMap::ScriptEventsResetAll(); LuaEventData::RemoveAll(); // Remove bindings for (std::map<int, std::vector<int> >::iterator itr = ServerEventBindings.begin(); itr != ServerEventBindings.end(); ++itr) { for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) luaL_unref(LuaState, LUA_REGISTRYINDEX, (*it)); itr->second.clear(); } CreatureEventBindings->Clear(); CreatureGossipBindings->Clear(); GameObjectEventBindings->Clear(); GameObjectGossipBindings->Clear(); ItemEventBindings->Clear(); ItemGossipBindings->Clear(); playerGossipBindings->Clear(); lua_close(LuaState); } } else AddScriptHooks(); LuaState = luaL_newstate(); TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, "Eluna Lua Engine loaded."); LoadedScripts loadedScripts; LoadDirectory("scripts", &loadedScripts); luaL_openlibs(LuaState); //Register Globals Here RegisterGlobals(LuaState); //Register Templates Here ElunaTemplate<Unit>::Register(LuaState); ElunaTemplate<GameObject>::Register(LuaState); ElunaTemplate<Group>::Register(LuaState); ElunaTemplate<Guild>::Register(LuaState); ElunaTemplate<QueryResult>::Register(LuaState); ElunaTemplate<Aura>::Register(LuaState); ElunaTemplate<WorldPacket>::Register(LuaState); ElunaTemplate<Item>::Register(LuaState); ElunaTemplate<Spell>::Register(LuaState); ElunaTemplate<Quest>::Register(LuaState); ElunaTemplate<Map>::Register(LuaState); ElunaTemplate<Corpse>::Register(LuaState); uint32 count = 0; char filename[200]; for (std::set<std::string>::const_iterator itr = loadedScripts.luaFiles.begin(); itr != loadedScripts.luaFiles.end(); ++itr) { strcpy(filename, itr->c_str()); if (luaL_loadfile(LuaState, filename) != 0) { TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "Eluna::Error loading `%s`.", itr->c_str()); report(LuaState); } else { int err = lua_pcall(LuaState, 0, 0, 0); if (err != 0 && err == LUA_ERRRUN) { TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "Eluna::Error loading `%s`.", itr->c_str()); report(LuaState); } } ++count; } if (restart) { //! Iterate over every supported source type (creature and gameobject) //! Not entirely sure how this will affect units in non-loaded grids. { TRINITY_READ_GUARD(HashMapHolder<Creature>::LockType, *HashMapHolder<Creature>::GetLock()); HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures(); for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter) if (iter->second->IsInWorld()) // must check? // if(sEluna->CreatureEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna? iter->second->AIM_Initialize(); } } TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, "Eluna::Loaded %u Lua scripts..", count); }
// Loads lua scripts from given directory void Eluna::LoadDirectory(char* Dirname, LoadedScripts* lscr) { #ifdef WIN32 HANDLE hFile; WIN32_FIND_DATA FindData; memset(&FindData, 0, sizeof(FindData)); char SearchName[MAX_PATH]; strcpy(SearchName, Dirname); strcat(SearchName, "\\*.*"); hFile = FindFirstFile(SearchName, &FindData); if (hFile == INVALID_HANDLE_VALUE) { TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "Eluna::No `scripts` directory found! Creating a 'scripts' directory and restarting Eluna."); CreateDirectory("scripts", NULL); StartEluna(true); return; } FindNextFile(hFile, &FindData); while ( FindNextFile(hFile, &FindData) ) { if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { strcpy(SearchName, Dirname); strcat(SearchName, "\\"); strcat(SearchName, FindData.cFileName); LoadDirectory(SearchName, lscr); } else { std::string fname = Dirname; fname += "\\"; fname += FindData.cFileName; size_t len = strlen(fname.c_str()); int i = 0; char ext[MAX_PATH]; while (len > 0) { ext[i++] = fname[--len]; if (fname[len] == '.') break; } ext[i++] = '\0'; if (!_stricmp(ext,"aul.")) lscr->luaFiles.insert(fname); } } FindClose(hFile); #else char* dir = strrchr(Dirname, '/'); if (strcmp(Dirname, "..") == 0 || strcmp(Dirname, ".") == 0) return; if (dir && (strcmp(dir, "/..") == 0 || strcmp(dir, "/.") == 0 || strcmp(dir, "/.svn") == 0)) return; struct dirent** list; int fileCount = scandir(Dirname, &list, 0, 0); if (fileCount <= 0 || !list) return; struct stat attributes; bool error; while (fileCount--) { char _path[200]; sprintf(_path, "%s/%s", Dirname, list[fileCount]->d_name); if (stat(_path, &attributes) == -1) { error = true; TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "Eluna::Error opening `%s`", _path); } else error = false; if (!error && S_ISDIR(attributes.st_mode)) LoadDirectory((char*)_path, lscr); else { char* ext = strrchr(list[fileCount]->d_name, '.'); if (ext && !strcmp(ext, ".lua")) lscr->luaFiles.insert(_path); } free(list[fileCount]); } free(list); #endif }
Directory::Directory (const char* name) { rep_ = new DirectoryRep; rep_->dir = nil; LoadDirectory(name); }