void ParseThread::ProcessSimple(ParseRequest* req) { wxString dbfile = req->getDbfile(); wxString file = req->getFile(); // Skip binary file if(TagsManagerST::Get()->IsBinaryFile(file)) { DEBUG_MESSAGE( wxString::Format(wxT("Skipping binary file %s"), file.c_str()) ); return; } // convert the file to tags TagsManager *tagmgr = TagsManagerST::Get(); ITagsStoragePtr db(new TagsStorageSQLite()); db->OpenDatabase( dbfile ); //convert the file content into tags wxString tags; wxString file_name(req->getFile()); tagmgr->SourceToTags(file_name, tags); int count; DoStoreTags(tags, file_name, count, db); db->Begin(); /////////////////////////////////////////// // update the file retag timestamp /////////////////////////////////////////// db->InsertFileEntry(file, (int)time(NULL)); //////////////////////////////////////////////// // Parse and store the macros found in this file //////////////////////////////////////////////// PPTable::Instance()->Clear(); PPScan( file, true ); db->StoreMacros( PPTable::Instance()->GetTable() ); PPTable::Instance()->Clear(); db->Commit(); // Parse the saved file to get a list of files to include ParseIncludeFiles(req, file, db ); // If there is no event handler set to handle this comaprison // results, then nothing more to be done if (req->_evtHandler ) { wxCommandEvent clearCacheEvent(wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE); req->_evtHandler->AddPendingEvent(clearCacheEvent); wxCommandEvent retaggingCompletedEvent(wxEVT_PARSE_THREAD_RETAGGING_COMPLETED); retaggingCompletedEvent.SetClientData( NULL ); req->_evtHandler->AddPendingEvent(retaggingCompletedEvent); } }
void create() { int i; string *files; seteuid((string)"/secure/master"->creator_file(file_name(this_object()))); if (!restore_object(SAVE_FILE)) { soul_data = ([ ]); files = get_dir(SOUL_DEF_DIR+"/"); for (i = 0; i < sizeof(files); i ++) { compile(files[i]); } }
int heal_up() { if(environment() && !is_fighting() && query("startroom") && file_name(environment()) != query("startroom")) { // command("say ok"); return_home(query("startroom")); return 1; } return ::heal_up() + 1; }
void Resurrector::restartFromFile() { Moose::setup_perf_log.push("restartFromFile()","Resurrector"); std::string file_name(_restart_file_base + ".xdr"); MooseUtils::checkFileReadable(file_name); _restartable.readRestartableDataHeader(_restart_file_base + RESTARTABLE_DATA_EXT); _fe_problem._eq.read(file_name, DECODE, EquationSystems::READ_DATA | EquationSystems::READ_ADDITIONAL_DATA, _fe_problem.adaptivity().isOn()); _fe_problem._nl.update(); Moose::setup_perf_log.pop("restartFromFile()","Resurrector"); }
void recreate_file() { // many thanks to Benjamin de Dardel! namespace fs = boost::filesystem; m_out = boost::shared_ptr< std::basic_ofstream<char_type> >(new std::basic_ofstream<char_type>( file_name(m_cur_idx).c_str(), m_flags.extra_flags() | std::ios_base::out | std::ios_base::app)); if ( fs::file_size( file_name(m_cur_idx)) > m_flags.max_size_bytes()) { // this file is already full - clear it first m_out = boost::shared_ptr< std::basic_ofstream<char_type> >(new std::basic_ofstream<char_type>( file_name(m_cur_idx).c_str(), m_flags.extra_flags() | std::ios_base::out | std::ios_base::trunc)); } }
int find_allbing(string str) { object *list; int number; object where; int i, count; count = 0; if(!str) return 0; list = children(str); number = sizeof(list); if(number) { for(i=0; i<sizeof(list); i++) { write((int)(i+1)+". "+file_name(list[i])+" "+ list[i]->query("name")+"("+list[i]->query("id")+") is at "); where=environment(list[i]); if(where) { if(where->query("short")) { write(where->query("short")); } else { write(where->short()); } write("("+file_name(where)+"), " ); write("owner_id: " + list[i]->query("owner_id") + "\n"); } else { write("???, "); write("owner_id: " + list[i]->query("owner_id") + "\n"); } } }
STATIC inline FILE *file() { static FILE *m_file = 0; static char buffer[buffer_size]; if (!m_file) { m_file = fopen(file_name(),"wb"); VERIFY (m_file); setvbuf (m_file,buffer,_IOFBF,buffer_size); } return (m_file); }
int event_pending(object ob) { mapping tmp; int *cles; string fn; int i; tmp = EVENTS_D->GetEvents(); fn = file_name(ob); i = sizeof(cles = keys(tmp)); while(i--) if( tmp[cles[i]]["object"] == fn ) return 1; return 0; }
bool BmpImageAsset::CanHandle( ) { if ( !m_IsOpen ) { bfs::path file_name( m_AssetName.c_str() ); file_name = operator/( m_DirectoryName.c_str(), file_name ); if (!bfs::exists( file_name )) { return m_IsOpen; } m_IsOpen = m_Context->open( file_name ); } return m_IsOpen; }
int hiddenp( object ob ) { string filename; int ret; if( !objectp( ob ) ) return 0; filename = file_name( ob ); seteuid( 0 ); ret = !find_object( filename ); seteuid( getuid( this_object() ) ); return ret; }
string base_name(mixed val) { if (nullp(val)) val = previous_object(); if (objectp(val)) val = file_name(val); else if (!stringp(val)) return val; sscanf(val, "%s#%*d", val); return val; }
void PDMPluginRender<Scalar, Dim>::onEndFrame(unsigned int frame) { if(this->auto_capture_frame_) { std::string file_name("./screen_shots/frame_"); std::stringstream adaptor; adaptor<<frame; std::string cur_frame_str; adaptor>>cur_frame_str; file_name += cur_frame_str + std::string(".png"); this->window_->saveScreen(file_name); }
void eventReceiveChannelWhoRequest(mixed *packet) { string *who; if (file_name(previous_object()) != INTERMUD_D) { return; } if (GetLocalChannel(packet[6])) { who = (string *)filter_array(users(), "filter_listeners", this_object(), packet[6])->query_cap_name(); } else { who = ({ }); }
void CNetScheduleJobSerializer::LoadJobInput(const string& source_file) { CNcbiIfstream input_stream(source_file.c_str(), CNcbiIfstream::binary); if (input_stream.fail() && !input_stream.eof()) { NCBI_THROW_FMT(CIOException, eRead, "Error while reading job input from '" << source_file << '\''); } string header; getline(input_stream, header); CAttrListParser attr_parser; attr_parser.Reset(header); CAttrListParser::ENextAttributeType attr_type; CTempString attr_name; string attr_value; size_t attr_column; #define ATTR_POS " at column " << attr_column while ((attr_type = attr_parser.NextAttribute(&attr_name, &attr_value, &attr_column)) != CAttrListParser::eNoMoreAttributes) { if (attr_name == "affinity") m_Job.affinity = attr_value; else if (attr_name == "group") m_Job.group = attr_value; else if (attr_name == "exclusive") { m_Job.mask = CNetScheduleAPI::eExclusiveJob; continue; } else { NCBI_THROW_FMT(CArgException, eInvalidArg, "unknown attribute '" << attr_name << "'" ATTR_POS); } if (attr_type != CAttrListParser::eAttributeWithValue) { NCBI_THROW_FMT(CArgException, eInvalidArg, "attribute '" << attr_name << "' requires a value" ATTR_POS); } } if (!input_stream.eof()) { CStringOrBlobStorageWriter job_input_writer( numeric_limits<size_t>().max(), NULL, m_Job.input); CWStream job_input_ostream(&job_input_writer, 0, NULL); NcbiStreamCopy(job_input_ostream, input_stream); } CDirEntry file_name(source_file); m_Job.job_id = file_name.GetBase(); }
int main(string str) { object *ob; int i; ob=users(); i = sizeof(ob); while (i--) { write(sprintf("%15s : %30s\n",ob[i]->query("id"), file_name(ob[i]))); } return 1; }
int main(object me, string arg) { string item, targ; object ob, owner; int price, afford; string fname,opfaname,faname=me->query("family/family_name"); string* slist; if( this_player()->is_busy() ) return notify_fail("你现在正忙着呢。\n"); if( !arg || sscanf(arg, "%s from %s", item, targ)!=2 ) return notify_fail ("指令格式:buy <某物> from <某人>\n"); if( !objectp(owner = present(targ, environment(me))) ) return notify_fail("你要跟谁买东西?\n"); if( userp(owner) ) { message_vision("$N想向$n购买「" + item + "」。\n", me, owner); notify_fail("对方好像不愿意跟你交易。\n"); return 1; } if( (price = owner->buy_object(me, item)) == -1 ) return 1; if( price < 1 ) return 0; fname=file_name(environment(me)); slist=explode(fname,"/"); opfaname=SHILI_D->query_family(slist[sizeof(slist)-2]); if((opfaname!="")&&(opfaname==faname)){ message_vision("$n对$N说,由于贵门多年照顾,就收您一半的钱了.\n",me,owner); price=price/2; } if((opfaname!="")&&faname&&(FAMILYD->family_relation(opfaname,faname)==-1)){ message_vision("$n对$N说,"+SHILI_D->query_master(opfaname)+"说了,卖给贵门派弟子的东西,价格都要翻倍。\n",me,owner); price=price*2; } if( afford = me->can_afford(price) ) { if( afford==2 ) return notify_fail("你没有足够的零钱,而银票又没人找得开。\n"); if(owner->complete_trade(me, item)) { me->pay_money(price); return 1; } else { return 0; } } else return notify_fail("你的钱不够。\n"); }
int getoid(object obj) { string name, dummy; int oid; if (!obj) { return -1; } name = file_name(obj); sscanf(name, "%s#%d", dummy, oid); return oid; }
void QSmartLabel::on_saveAction_triggered() { const QImage _img = this->pixmap()->toImage(); QFileInfo file_name(QFileDialog::getSaveFileName(0, "Img",0,"PNG (*.png);;BMP (*.bmp);;JPG (*.jpg)")); if(file_name.fileName().isNull()) { return; } if(!_img.isNull()) { _img.save(file_name.absoluteFilePath()); } else{QMessageBox::information(0, 0, "Can Not Save Image!!");} }
void do_tests() { #ifndef __NO_ENVIRONMENT__ int s = sizeof(all_inventory(this_object())); ASSERT(sizeof(all_inventory()) == s); for (int i = 0; i < 5; i++) { ASSERT(sizeof(all_inventory()) == s + i); clone_object(file_name()); } ASSERT(filter(all_inventory(this_object()), (: !$1->is_all_inv_test() :))); #endif }
void file_modify(FDSC **curr,char *fixed) { FDSC **this,*next; if (!(this = file_find(curr,fixed))) die("Internal error: file_find failed"); switch ((*this)->type) { case fdt_drop: printf("Dropping %s\n",file_name(fixed)); *(unsigned char *) fixed = DELETED_FLAG; break; case fdt_undelete: *fixed = *(*this)->name; printf("Undeleting %s\n",file_name(fixed)); break; default: die("Internal error: file_modify"); } next = (*this)->next; free(*this); *this = next; }
varargs string name(int raw) { string str, *mask; if( !raw && sizeof(mask = query_temp("apply/name")) ) return mask[sizeof(mask)-1]; else { if( stringp(str = query("name")) ) return str; else return file_name(this_object()); } }
nomask int set_access(string entry, int new_access) { string eff_user; int curr_access; // first, get the identity of who is trying to change the access. if (!previous_object()) eff_user = geteuid(); else eff_user = geteuid(previous_object()); #ifdef DEBUG write(eff_user + " is trying to change access " + entry + " to " + new_access + " for " + file_name(this_object()) + "\n"); #endif // Only two euid can generally change the permissions on things. // the owner, because it makes sense, and Root, just because. if (eff_user != geteuid(this_object()) && eff_user != ROOT_UID) return 0; // now get it's protection level. // then, switch through the various types of protection. curr_access = check_access(entry); if(!intp(curr_access)) curr_access = 0; switch(curr_access) { case PUBLIC: case READ_ONLY: case OWNER_ONLY: perms[entry] = new_access; return 1; break; case LOCKED: case PRIVATE: return 0; break; case MASTER_ONLY: if (eff_user == ROOT_UID) { perms[entry] = new_access; return 1; } return 0; break; default: // the item isn't even in priv.h - probably an error perms[entry] = new_access; return 1; break; } }
int conjure(object me, object target) { int lvl; // if(me->query("class")!="bonze") // return notify_fail("只有兴国禅寺的弟子才可以使用寂识神通!\n"); lvl = (int) me->query_skill("essencemagic",1); if (lvl<30) return notify_fail("你八识神通的修为不够,无法使用寂识神通。\n"); if (me->is_fighting()) return notify_fail("寂识神通不能在战斗中使用。\n"); if (domain_file(file_name(environment(me)))=="eren2" || environment(me)->query("no_fly") ) return notify_fail("此地不能使用寂识神通。\n"); if (me->query("class")!="bonze") if (me->query("timer/silent")) if (lvl<me->query("timer/silent_level")) return notify_fail("你需要继续修炼八识神通才能使用寂识神通。\n"); if(target) return notify_fail("寂识神通只能对自己使用。\n"); if( me->query("atman") < 100 ) return notify_fail("你的灵力不够!\n"); if( me->query("gin") <= 50 ) return notify_fail("你的精力不够!\n"); me->add("atman", -100); me->receive_damage("gin", 50); message_vision(HIY "$N盘膝而座,开始运用寂识神通静思入定 ...\n" NOR, me); if(random(me->query_skill("essencemagic",1))+14< me->query_skill("essencemagic",1) && !me->is_fighting()) { tell_object(me,HIW"你的周围一片寂静,你感觉身体不断的下沉。\n"NOR); me->move("/d/death/yanluo"); me->be_ghost(1); me->start_busy(5); return 1; } write("可是什么事情都没有发生。\n"); if (me->query("class")!="bonze") me->add("timer/silent",1); if (me->query("class")!="bonze" && me->query("timer/silent")>150){ tell_object(me,HIR"你既非禅门弟子,八识神通就该勤加练习才能继续使用。\n"NOR); me->set("timer/silent_level",lvl+1); me->set("timer/silent",1); } return 1; }
TestFWParser::TestFWParser(): QObject() { test_cases_.append( "this is an exam ple of 256 cases being tested -3.14 times\n"); test_cases_.append( " \n"); test_cases_.append("this is an ex\n\n"); QString file_name("TestFW.txt"); file_name = KStandardDirs::locateLocal("appdata", file_name); if (!file_name.isNull()) { test_file_.setFileName(file_name); if (!test_file_.open(QIODevice::WriteOnly)) { kWarning() << QString("Couldn't open(%1)").arg(file_name); } } QTextStream out_stream(&test_file_); foreach(const QString &test_case, test_cases_) out_stream << test_case; test_file_.close(); //Building the sequence to be used. Includes all available types. sequence_.clear(); sequence_.append(qMakePair(QString("field1"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field2"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field3"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field4"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field5"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field6"), KSParser::D_INT)); sequence_.append(qMakePair(QString("field7"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field8"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field9"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field10"), KSParser::D_FLOAT)); sequence_.append(qMakePair(QString("field11"), KSParser::D_QSTRING)); sequence_.append(qMakePair(QString("field12"), KSParser::D_QSTRING)); widths_.append(5); widths_.append(3); widths_.append(3); widths_.append(9); widths_.append(3); widths_.append(4); widths_.append(6); widths_.append(6); widths_.append(7); widths_.append(6); widths_.append(6); //'repeatedly' doesn't need a width QString fname = KStandardDirs::locate( "appdata", file_name ); test_parser_ = new KSParser(fname, '#', sequence_, widths_); }
int main(int argc, char **argv) { // Define the display size_t width = 640, height = 480; // the model name can be specified on the command line. std::string file_name(argv[1]), file_ext = file_name.substr(file_name.size() - 3, file_name.npos); if (file_ext == "png") render2d(file_name, width, height); else render3d(file_name, width, height); return 0; }
void remove_eternal_fate(mixed ob) { string keyword; if (stringp(ob)) keyword = ob; else if (objectp(ob)) { keyword = ob->query("fate_keyword"); if (!keyword) keyword = file_name(ob); } else return; map_delete(eternal_fates, keyword); }
//------------------------------------------------------------------------------ // // Stem of a given file (no path, no extension) // //------------------------------------------------------------------------------ std::string file_stem(const std::string &path) { if (path == "") return path; // get a file name from the path const std::string fname = file_name(path); // extract a stem and return it size_t pos = fname.find_last_of('.'); if (pos == std::string::npos) return fname; // there is no '.', so this is the stem return fname.substr(0, pos); }
void test01() { std::string file_name("image.bmp"); bitmap_image image(file_name); if (!image) { printf("test01() - Error - Failed to open '%s'\n",file_name.c_str()); return; } image.save_image("test01_saved.bmp"); }
//------------------------------------------------------------------------------ // // Extension of a given file // //------------------------------------------------------------------------------ std::string file_extension(const std::string &path) { if (path == "") return path; // extract a file name from the path const std::string fname = file_name(path); size_t pos = fname.find_last_of('.'); if (pos == std::string::npos) return ""; // there is no '.', so there is no extension // extract an extension and return it return fname.substr(pos); }
void reset(){ object *inv; int num,i; ::reset(); inv = all_inventory(); for (i=0;i<sizeof(inv);i++){ if (userp(inv[i])) { message_vision(HIW"李寻欢用尽全身力量,将$N从流沙中救了出来。\n"NOR, inv[i]); sscanf(file_name(this_object()),__DIR__"quiclsamd%d",num); inv[i]->move(__DIR__"desert"+num); tell_object(inv[i],CYN"\n李寻欢拍拍你的脑袋,以后小心啦,说罢便消失了!\n\n"NOR); } } }