void LLWaterParamManager::loadAllPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); LL_INFOS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL; bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); if(found) { name=name.erase(name.length()-4); // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_unescape(name.c_str(), name.size()); std::string unescaped_name(curl_str); curl_free(curl_str); curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; loadPreset(unescaped_name,FALSE); } } // And repeat for user presets, note the user presets will modify any system presets already loaded std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); LL_INFOS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL; found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); if(found) { name=name.erase(name.length()-4); // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_unescape(name.c_str(), name.size()); std::string unescaped_name(curl_str); curl_free(curl_str); curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; loadPreset(unescaped_name,FALSE); } } }
BmpImageAsset::BmpImageAsset( const char* n ) : VideoAsset( n ) , m_AssetName(n) , m_FileExtension(".bmp") , m_IsOpen(false) , m_Surface( new pei::Surface ) // create dummy surface , m_Context( new BmpPrivateContext ) { bfs::path path_name( n ); if ( bfs::exists( path_name ) && !bfs::is_directory( path_name ) ) { m_DirectoryName = path_name.parent_path().string(); m_AssetName = path_name.filename(); } }
F32 lggBeamMaps::setUpAndGetDuration() { static LLCachedControl<std::string> settingNameCached(gSavedSettings, "FSBeamShape"); std::string settingName(settingNameCached); if (settingName != mLastFileName) { mLastFileName = settingName; if (!settingName.empty()) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", "")); std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beams", "")); std::string filename = path_name + settingName + ".xml"; if (!gDirUtilp->fileExists(filename)) { filename = path_name2 + settingName + ".xml"; } LLSD mydata = getPic(filename); mScale = (F32)mydata["scale"].asReal() / 10.0f; LLSD myPicture = mydata["data"]; mDots.clear(); for (LLSD::array_iterator it = myPicture.beginArray(); it != myPicture.endArray(); ++it) { LLSD beamData = *it; lggBeamData dot; dot.p = LLVector3d(beamData["offset"]); static LLCachedControl<F32> FSBeamShapeScale(gSavedSettings, "FSBeamShapeScale"); dot.p *= (FSBeamShapeScale * 2.0f); LLColor4 color = LLColor4(beamData["color"]); dot.c = LLColor4U(color); mDots.push_back(dot); } static LLCachedControl<F32> FSMaxBeamsPerSecond(gSavedSettings, "FSMaxBeamsPerSecond"); F32 maxBPerQS = FSMaxBeamsPerSecond / 4.0f; mDuration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f; LL_INFOS("LGG_Beams") << "reading it all now size is " << myPicture.size() << " and duration is " << mDuration << LL_ENDL; } else { mDots.clear(); mScale = 0.0f; //used as a flag too mDuration = 0.25f; } } return mDuration; }
GOrgueHashType GOrgueArchiveIndex::GenerateHash() { GOrgueHash hash; hash.Update(sizeof(wxString)); hash.Update(sizeof(GOArchiveEntry)); hash.Update(sizeof(size_t)); wxFileName path_name(m_Path); uint64_t size = path_name.GetSize().GetValue(); uint64_t time = path_name.GetModificationTime().GetTicks(); hash.Update(time); hash.Update(size); return hash.getHash(); }
std::vector <std::string> lggHunSpell_Wrapper::getExtraDicts() { std::vector<std::string> names; std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", "")); bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false); if(found) { names.push_back(dictName2FullName(name)); } } return names; }
int fs_ulink(const char *path) { uint64_t dir; char *parent; char *name; int err; parent = path_parent(path); name = path_name(path); dir = fs_find(parent); err = rp_ulink(dir, name); free(parent); free(name); return err; }
static void show_object(struct object *obj, const struct name_path *path, const char *component) { /* An object with name "foo\n0000000..." can be used to * confuse downstream git-pack-objects very badly. */ const char *name = path_name(path, component); const char *ep = strchr(name, '\n'); if (ep) { fprintf(pack_pipe, "%s %.*s\n", sha1_to_hex(obj->sha1), (int) (ep - name), name); } else fprintf(pack_pipe, "%s %s\n", sha1_to_hex(obj->sha1), name); free((char *)name); }
std::vector <std::string> lggHunSpell_Wrapper::getExtraDicts() { std::vector<std::string> names; std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", "")); std::string name; LLDirIterator app_iter(path_name, "*.dic"); while (app_iter.next(name)) { names.push_back(dictName2FullName(name)); } path_name = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", ""); LLDirIterator user_iter(path_name, "*.dic"); while (user_iter.next(name)) { names.push_back(dictName2FullName(name)); } return names; }
static void show_object(struct object *obj, const struct name_path *path, const char *component) { char *name = path_name(path, component); /* An object with name "foo\n0000000..." can be used to * confuse downstream "git pack-objects" very badly. */ const char *ep = strchr(name, '\n'); finish_object(obj, path, name); if (ep) { printf("%s %.*s\n", sha1_to_hex(obj->sha1), (int) (ep - name), name); } else printf("%s %s\n", sha1_to_hex(obj->sha1), name); free(name); }
bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_disk) { // remove from param list std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); if(mIt != mParamList.end()) { mParamList.erase(mIt); } F32 key; // remove all references bool stat = true; do { // get it stat = mDay.getKey(name, key); if(stat == false) { break; } // and remove stat = mDay.removeKey(key); } while(stat == true); if(delete_from_disk) { std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); // use full curl escaped name char * curl_str = curl_escape(name.c_str(), name.size()); std::string escaped_name(curl_str); curl_free(curl_str); curl_str = NULL; gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); } notifyObservers(); return true; }
void LLWaterParamManager::loadAllPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading Default water settings from " << path_name << LL_ENDL; bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); if(found) { name=name.erase(name.length()-4); std::string unescaped_name = LLCurl::unescapeSafe(name); LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; loadPreset(unescaped_name,FALSE); } } // And repeat for user presets, note the user presets will modify any system presets already loaded std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading User water settings from " << path_name2 << LL_ENDL; found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); if(found) { name=name.erase(name.length()-4); std::string unescaped_name = LLCurl::unescapeSafe(name); LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; loadPreset(unescaped_name,FALSE); } } }
int fs_link(const char *path, const char *link) { uint64_t dir; uint64_t rp; char *parent; char *name; int err; parent = path_parent(path); name = path_name(path); rp = fs_find(link); dir = fs_find(parent); err = rp_link(dir, name, rp); free(parent); free(name); return err; }
/*! * \brief 出力ストリームの参照 * \return 出力ストリーム * * 設定されているファイルに出力するための出力ストリームを返す。 * 既に出力ストリームが生成されている場合はその参照を返し、そうでなければ新たに出力ストリームを生成する。 * * ファイル名として、"stdout"が設定されていれば標準出力、"stderr"が設定されていれば標準エラー出力になる。 */ std::ostream& output_file::ostr() const { if ( filename_ == "stdout" ) { return std::cout; } else if ( filename_ == "stderr" ) { return std::cerr; } std::string path( path_name( filename_ ) ); context_map::const_iterator iter( get_context_map().find( path ) ); if ( iter == get_context_map().end() ) { std::tr1::shared_ptr< context > ctx( new context ); get_context_map().insert( std::make_pair( path, ctx ) ); return ctx->ostr; } return iter->second->ostr; }
bool AscentDayCycleManager::removeParamSet(const std::string& name, bool delete_from_disk) { // remove from param list std::map<std::string, LLWLDayCycle>::iterator mIt = mParamList.find(name); if(mIt != mParamList.end()) { mParamList.erase(mIt); } F32 key; // remove all references bool stat = true; do { // get it stat = mDay.getKey(name, key); if(stat == false) { break; } // and remove stat = mDay.removeKey(key); } while(stat == true); if(delete_from_disk) { std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", "")); // use full curl escaped name std::string escaped_name = LLWeb::curlEscape(name); gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); } return true; }
bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_from_disk) { // remove from param list std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); if(mIt != mParamList.end()) { mParamList.erase(mIt); } if(delete_from_disk) { std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); // use full curl escaped name std::string escaped_name = LLCurl::escapeSafe(name); gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); } return true; }
/* Put 'fname\0sname\0' into buf and return pointer to sname * Put '\0hexval\0' into buf and return pointer to hexval if * sym cannot be resolved */ unsigned char * dbug_resolve_symbol(void *sym, unsigned char *buf, unsigned char *blim) { Dl_info info; const char *name; if (dladdr(sym, &info) == 0) { *buf++ = '\0'; /* no filename */ dsnprintf(buf, blim - buf, "%p", sym); return buf; } name = info.dli_fname; name = path_name((unsigned char *)name, (unsigned char *)name + 255, '/'); buf += str_copy(name, name + 255, buf, blim, -1) + 1; name = info.dli_sname; str_copy(name, name + 255, buf, blim, -1); return buf; }
bool LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) { // *NOTE: Removing a sky preset invalidates day cycles that refer to it. if (key.scope == LLEnvKey::SCOPE_REGION) { llwarns << "Removing region skies not supported" << llendl; llassert(key.scope == LLEnvKey::SCOPE_LOCAL); return false; } // remove from param list std::map<LLWLParamKey, LLWLParamSet>::iterator it = mParamList.find(key); if (it == mParamList.end()) { LL_WARNS("WindLight") << "No sky preset named " << key.name << LL_ENDL; return false; } mParamList.erase(it); mDay.removeReferencesTo(key); // remove from file system if requested if (delete_from_disk) { std::string path_name(getUserDir()); std::string escaped_name = LLWeb::curlEscape(key.name); if(gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml") < 1) { LL_WARNS("WindLight") << "Error removing sky preset " << key.name << " from disk" << LL_ENDL; } } // signal interested parties mPresetListChangeSignal(); return true; }
int main(int argc, char *argv[]) { // MNM_IO::build_node_factory(test_dta -> m_file_folder, test_dta->m_config, test_dta->m_node_factory); // std::cout << test_dta -> m_node_factory -> m_node_map.size() << "\n"; // MNM_IO::build_link_factory(test_dta -> m_file_folder, test_dta->m_config, test_dta->m_link_factory); // std::cout << test_dta -> m_link_factory -> m_link_map.size() << "\n"; // MNM_IO::build_od_factory(test_dta -> m_file_folder, test_dta->m_config, test_dta->m_od_factory, test_dta->m_node_factory); // std::cout << test_dta -> m_od_factory -> m_origin_map.size() << "\n"; // std::cout << test_dta -> m_od_factory -> m_destination_map.size() << "\n"; // test_dta -> m_graph = MNM_IO::build_graph(test_dta -> m_file_folder,test_dta -> m_config); // test_dta -> m_graph -> Dump(); // MNM_Dta *test_dta = new MNM_Dta("../../data/input_files_new_philly"); // MNM_Dta *test_dta = new MNM_Dta("../../data/input_files_SR41"); // MNM_Dta *test_dta = new MNM_Dta("../../data/input_files_7link"); // MNM_Dta *test_dta = new MNM_Dta("../../data/input_files_1link"); // MNM_Dta *test_dta = new MNM_Dta("../../data/input_files_PGH"); if (argc != 2){ printf("Usage: ./dta_response . (do not forget the second argument)\n"); return -1; } printf("Current working directory is......\n"); std::cout << argv[1] << std::endl; std::string path_name(argv[1]); MNM_Dta *test_dta = new MNM_Dta(path_name); test_dta -> build_from_files(); printf("Hooking......\n"); test_dta -> hook_up_node_and_link(); // printf("Checking......\n"); // test_dta -> is_ok(); test_dta -> loading(true); printf("Finished Loading!\n"); delete test_dta; return 0; }
void Process(StrLen file_name) { SplitPath dev_name(file_name); SplitName path_name(dev_name.path); SplitExt name_ext(path_name.name); String in_name; if( !name_ext ) { in_name=StringCat(dev_name.dev,path_name.path,name_ext.name,".lang"); } else { in_name=file_name; } TrackStage("Load file #.q;",StrLen(Range(in_name))); CondLang clang(Range(in_name)); TrackStage("Build top lang"); TopLang top(clang); TrackStage("Run good test on top lang"); if( !RunGoodTest(top) ) return; TrackStage("Build bottom lang"); BottomLang bottom(clang); TrackStage("Extend bottom lang"); ExtLang ext_bottom(bottom); TrackStage("Process top lang"); ExtLang ext_top(top); LangDiagram diagram(ext_top); LangStateMachine<LR1Estimate,LR1MapContext> machine(ext_top,diagram,ext_bottom); StateCompress<LR1Estimate> compress(machine); TrackStage("LR1) #;",PrintCompressCounts(compress)); { ulen conflicts=0; for(auto &est : compress.getProps() ) conflicts+=est.hasConflict(); if( conflicts ) { String out_name=StringCat(dev_name.dev,path_name.path,name_ext.name,".bad.txt"); PrintFile out(Range(out_name)); Putobj(out,clang); PrintBad(out,ext_top,compress); Printf(Exception,"#; CONFLICTs detected. Not LR1 language.",conflicts); } else { TrackStage("No conflicts. LR1 language."); } } StateCompress<LR1Estimate,LR1PropNonEmpty> compress_ne(machine); TrackStage("NonEmpty) #;",PrintCompressCounts(compress_ne)); #if 0 StateCompress<LR1Estimate,LR1PropShiftSet> compress_shift(machine); TrackStage("Shift) #;",PrintCompressCounts(compress_shift)); StateCompress<LR1Estimate,LR1PropValidSet> compress_valid(machine); TrackStage("Valid) #;",PrintCompressCounts(compress_valid)); StateCompress<LR1Estimate,LR1PropRuleSet> compress_rules(machine); TrackStage("Rules) #;",PrintCompressCounts(compress_rules)); StateMap map(compress,compress_ne); String out_name=StringCat(dev_name.dev,path_name.path,"Result.txt"); PrintFile out(Range(out_name)); PrintFibres(out,compress,compress_ne,map); Putobj(out,BindOpt(ext_top,compress_ne)); #endif { String out_name=StringCat(dev_name.dev,path_name.path,name_ext.name,".txt"); PrintFile out(Range(out_name)); Putobj(out,clang); Putobj(out,BindOpt(ext_top,compress)); } { String out_name=StringCat(dev_name.dev,path_name.path,name_ext.name,".ddl"); PosPrint<PrintFile> out(Range(out_name)); Printf(out,"/* #;.ddl */\n\n",name_ext.name); Putobj(out,"//include <LangTypes.ddl>\n\n"); Putobj(out,"Lang lang=\n"); // lang { ListPrint<decltype(out)> lang_out(out); // atoms { ListPrint<decltype(lang_out)> atom_out(lang_out); for(auto &atom : clang.getAtoms() ) Printf(atom_out,"{ #; , #; , lang.elements+#; }#;",atom.index,StrLen(atom.name.inner(2,1)),atom.index,EndItem()); Putobj(atom_out,EndList()); } Putobj(lang_out,EndItem()); // synts { ListPrint<decltype(lang_out)> synt_out(lang_out); ulen element=clang.getAtomCount(); ulen top_index=0; for(auto &synt : clang.getSynts() ) { Printf(synt_out,"{ #; , #.q; ,",synt.index,synt.name); auto kinds=synt.kinds; if( !kinds ) { Indent indent(synt_out.getCol()); Printf(synt_out," { { #; , 0 , \"\" , lang.synts+#; , lang.elements+#; ,#;",top_index,synt.index,element++,AutoIndent()); auto &top_synt=top.getSynts()[top_index++]; ListPrint<decltype(synt_out)> rule_out(synt_out); for(auto &top_rule : top_synt.rules ) Printf(rule_out,"lang.top_rules+#;#;",top_rule.index,EndItem()); Putobj(rule_out,EndList()); Printf(synt_out,"#; }#; } ,#;",indent,indent,indent); } else { Indent indent(synt_out.getCol()); Putobj(synt_out,indent); ListPrint<decltype(synt_out)> kind_out(synt_out); for(auto &kind : kinds ) { Printf(kind_out,"{ #; , #; , #.q; , lang.synts+#; , lang.elements+#; ,#;",top_index,kind.index,kind.name,synt.index,element++,AutoIndent()); auto &top_synt=top.getSynts()[top_index++]; ListPrint<decltype(kind_out)> rule_out(kind_out); for(auto &top_rule : top_synt.rules ) Printf(rule_out,"lang.top_rules+#;#;",top_rule.index,EndItem()); Putobj(rule_out,EndList()); Printf(kind_out,"\n}#;",EndItem()); } Putobj(kind_out,EndList()); Putobj(synt_out," ,",indent); } ListPrint<decltype(synt_out)> rule_out(synt_out); for(auto &rule : synt.rules ) Printf(rule_out,"lang.rules+#;#;",rule.index,EndItem()); Putobj(rule_out,EndList()); Putobj(synt_out,"\n}",EndItem()); } Putobj(synt_out,EndList()); } Putobj(lang_out,EndItem()); // lang { ListPrint<decltype(lang_out)> synt_out(lang_out); for(auto &synt : clang.getSynts() ) if( synt.is_lang ) { Printf(synt_out,"lang.synts+#;",synt.index); } Putobj(synt_out,EndList()); } Putobj(lang_out,EndItem()); // elements { ListPrint<decltype(lang_out)> elem_out(lang_out); ulen element=0; for(auto &atom : clang.getAtoms() ) Printf(elem_out,"{ #; , lang.atoms+#; }#;",element++,atom.index,EndItem()); for(auto &synt : clang.getSynts() ) { auto len=synt.kinds.len; if( !len ) len=1; for(ulen i=0; i<len ;i++) { Printf(elem_out,"{ #; , lang.synts[#;].kinds+#; }#;",element++,synt.index,i,EndItem()); } } Putobj(elem_out,EndList()); } Putobj(lang_out,EndItem()); // rules { ListPrint<decltype(lang_out)> rule_out(lang_out); for(auto &rule : clang.getRules() ) { Printf(rule_out,"{ #; , #.q; , lang.synts[#;].kinds+#; ,#;",rule.index,rule.name,rule.ret->index,rule.getKindIndex(),AutoIndent()); ListPrint<decltype(rule_out)> arg_out(rule_out); for(auto &element : rule.args ) element.apply( [&] (const CondLangBase::AtomDesc *desc) { Printf(arg_out,"lang.atoms+#;#;",desc->index,EndItem()); } , [&] (const CondLangBase::SyntDesc *desc) { Printf(arg_out,"lang.synts+#;#;",desc->index,EndItem()); } ); Putobj(arg_out,EndList()); Putobj(rule_out,"\n}",EndItem()); } Putobj(rule_out,EndList()); } Putobj(lang_out,EndItem()); // top rules { ListPrint<decltype(lang_out)> rule_out(lang_out); for(auto &rule : top.getRules() ) { Printf(rule_out,"{ #; , #.q; , lang.rules+#; , lang.synts[#;].kinds+#; ,#;", rule.index,rule.name,rule.map_index,rule.ret->map_index,rule.ret->kind_index,AutoIndent()); ListPrint<decltype(rule_out)> arg_out(rule_out); for(auto &element : rule.args ) element.apply( [&] (const LangBase::AtomDesc *desc) { Printf(arg_out,"lang.atoms+#;#;",desc->index,EndItem()); } , [&] (const LangBase::SyntDesc *desc) { Printf(arg_out,"lang.synts[#;].kinds+#;#;",desc->map_index,desc->kind_index,EndItem()); } ); Putobj(arg_out,EndList()); Putobj(rule_out,"\n}",EndItem()); } Putobj(rule_out,EndList()); } Putobj(lang_out,EndItem()); // states { ListPrint<decltype(lang_out)> state_out(lang_out); for(auto &state : compress.getStateTable() ) { Printf(state_out,"{ #; , lang.finals+#; ,#;",state.index,state.prop_index,AutoIndent()); ListPrint<decltype(state_out)> trans_out(state_out); for(auto &trans : state.transitions ) Printf(trans_out,"{ lang.elements+#; , lang.states+#; }#;",trans.element,trans.dst->index,EndItem()); Putobj(trans_out,EndList()); Putobj(state_out,"\n}",EndItem()); } Putobj(state_out,EndList()); } Putobj(lang_out,EndItem()); // finals { ListPrint<decltype(lang_out)> final_out(lang_out); ulen atom_count=clang.getAtomCount(); ulen index=0; for(auto &final : compress.getProps() ) { Printf(final_out,"{ #; ,#;",index++,AutoIndent()); ListPrint<decltype(final_out)> action_out(final_out); if( final.hasNull() ) { Printf(action_out,"{ null , null }#;",EndItem()); } else { auto &alpha=final.getAlpha(); if( alpha.nonEmpty() ) { Printf(action_out,"{ null , lang.rules+#; }#;",alpha.getPtr()->getIndex()-atom_count,EndItem()); } } for(auto &rec : Range(final.getBeta()) ) { if( rec.object.shift ) { Printf(action_out,"{ lang.atoms+#; , null }#;",rec.index.getIndex(),EndItem()); } else { auto &rules=rec.object.rules; if( rules.nonEmpty() ) { Printf(action_out,"{ lang.atoms+#; , lang.rules+#; }#;",rec.index.getIndex(),rules.getPtr()->getIndex()-atom_count,EndItem()); } } } Putobj(action_out,EndList()); Putobj(final_out,"\n}",EndItem()); } Putobj(final_out,EndList()); } Putobj(lang_out,EndItem(),EndList()); } Putobj(out,";\n\n"); }
entry_t *traverse(void) /* Get one name from the directory tree. */ { static int depth; static pathname_t path; static entry_t entry; static namelist_t **entries; static size_t *trunc; static size_t deep; static namelist_t *newentries; struct stat st; recurse: keep= KEEP_TRAVERSE; if (deep == 0) { /* Initialize for the root of the tree. */ path_init(&path); path_add(&path, tree); entries= allocate(nil, 1 * sizeof(entries[0])); entries[0]= allocate(nil, sizeof(*entries[0])); entries[0]->next= nil; entries[0]->name= copystr("/"); trunc= allocate(nil, 1 * sizeof(trunc[0])); trunc[0]= path_length(&path); deep= 1; } else if (newentries != nil) { /* Last entry was a directory, need to go down. */ if (entry.ignore) { /* Ouch, it is to be ignored! */ while (newentries != nil) (void) pop_name(&newentries); goto recurse; } if (++depth == deep) { deep++; entries= allocate(entries, deep * sizeof(entries[0])); trunc= allocate(trunc, deep * sizeof(trunc[0])); } entries[depth]= newentries; newentries= nil; trunc[depth]= path_length(&path); } else { /* Pop up out of emptied directories. */ while (entries[depth] == nil) { if (depth == 0) return nil; /* Back at the root. */ /* Go up one level. */ depth--; } } entry.name= pop_name(&entries[depth]); path_trunc(&path, trunc[depth]); path_add(&path, entry.name); if (depth == 0) { entry.path= "/"; } else { entry.path= path_name(&path) + trunc[0]; if (entry.path[0] == '/') entry.path++; } entry.depth= depth; entry.ignore= 0; if (lstat(path_name(&path), &st) < 0) { if (depth == 0 || errno != ENOENT) { /* Something wrong with this entry, complain about * it and ignore it further. */ entry.ignore= errno; report(path_name(&path)); return &entry; } else { /* Entry strangely nonexistent; simply continue. */ goto recurse; } } /* Don't cross mountpoints if -x is set. */ if (xflag) { if (xdev == NO_DEVICE) xdev= st.st_dev; if (st.st_dev != xdev) { /* Ignore the mountpoint. */ entry.ignore= EXDEV; return &entry; } } entry.mode= st.st_mode & 07777; entry.uid= st.st_uid; entry.gid= st.st_gid; entry.size= st.st_size; entry.mtime= st.st_mtime; entry.rdev= st.st_rdev; linked(&entry, &st); if (S_ISDIR(st.st_mode)) { /* A directory. */ entry.type= F_DIR; /* Gather directory entries for the next traverse. */ if ((newentries= collect(path_name(&path))) == nil && errno != 0) { entry.ignore= errno; report(path_name(&path)); } } else if (S_ISREG(st.st_mode)) { /* A plain file. */ entry.type= F_FILE; } else if (S_ISBLK(st.st_mode)) { /* A block special file. */ entry.type= F_BLK; } else if (S_ISCHR(st.st_mode)) { /* A character special file. */ entry.type= F_CHR; } else if (S_ISFIFO(st.st_mode)) { /* A named pipe. */ entry.type= F_PIPE; } else if (S_ISLNK(st.st_mode)) { /* A symbolic link. */ entry.type= F_LINK; if ((entry.link= rdlink(path_name(&path), st.st_size)) == nil) { entry.ignore= errno; report(path_name(&path)); } } else { /* Unknown type of file. */ entry.ignore= EINVAL; } return &entry; }
void LLWLParamManager::loadPresets(const std::string& file_name) { // if fileName exists, use legacy loading form the big file, otherwise, search the sky // directory, and add the list if(file_name != "") { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; llifstream presetsXML(path_name); if (presetsXML) { LLSD paramsData(LLSD::emptyMap()); LLPointer<LLSDParser> parser = new LLSDXMLParser(); parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); LLSD::map_const_iterator endParams = paramsData.endMap(); for(LLSD::map_const_iterator curParams = paramsData.beginMap(); curParams != endParams; ++curParams) { addParamSet(curParams->first, curParams->second); } } } // otherwise, search the sky directory and find things there else { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; //mParamList.clear(); bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; // if we have one if(found) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_unescape(name.c_str(), name.size()); std::string unescaped_name(curl_str); curl_free(curl_str); curl_str = NULL; // not much error checking here since we're getting rid of this std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4); std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name)); LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL; llifstream sky_xml(cur_path); if (sky_xml) { LLSD sky_data(LLSD::emptyMap()); LLPointer<LLSDParser> parser = new LLSDXMLParser(); parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED); addParamSet(sky_name, sky_data); sky_xml.close(); } } } } }
entry_t *readstate(void) /* Read one entry from the state file. */ { static entry_t entry; static pathname_t path; static size_t *trunc; static size_t trunc_len; static base_indent; char *line; char **argv; size_t argc; static off_t lineno; int indent, depth; recurse: keep= KEEP_STATE; if (feof(statefp) || (line= read1line(statefp)) == nil) { checkstate(); return nil; } lineno++; /* How far is this entry indented? */ indent= 0; while (*line != 0) { if (*line == ' ') indent++; else if (*line == '\t') indent= (indent + 8) & ~7; else break; line++; } if (indent > 0 && base_indent == 0) base_indent= indent; depth= (base_indent == 0 ? 0 : indent / base_indent) + 1; if (entry.ignore && depth > entry.depth) { /* If the old directory is ignored, then so are its entries. */ goto recurse; } entry.depth= depth; splitline(line, &argv, &argc); if (argc < 2) state_syntax(lineno); if (trunc == nil) { /* The root of the tree, initialize path. */ if (argv[0][0] != '/') state_syntax(lineno); path_init(&path); path_add(&path, "/"); trunc= allocate(nil, (trunc_len= 16) * sizeof(trunc[0])); /* The root has depth 0. */ entry.depth= 0; trunc[0]= 0; } else { if (entry.depth > trunc_len) { trunc= allocate(trunc, (trunc_len*= 2) * sizeof(trunc[0])); } path_trunc(&path, trunc[entry.depth - 1]); path_add(&path, argv[0]); trunc[entry.depth]= path_length(&path); } entry.path= path_name(&path); entry.name= argv[0]; entry.link= nil; if ((entry.ignore= strcmp(argv[1], "ignore") == 0)) { return &entry; } if (!getattributes(&entry, argc - 1, argv + 1)) state_syntax(lineno); return &entry; }