void Program::Compile( const char *filename ) { char *src; Compiler compiler( *this ); int filenum; str oldfile( s_file ); s_file = filename; if ( gi.FS_ReadFile( filename, ( void ** )&src, true ) < 0 ) { s_file = oldfile; gi.WPrintf( "***\n***\n***\n*** Couldn't load %s\n***\n***\n***\n", filename ); throw "Error"; } filenum = filenames.AddObject( s_file ); //if ( !compiler.CompileFile( src, filename, filenum ) ) if ( !compiler.CompileFile( src, filenum ) ) { s_file = oldfile; gi.FS_FreeFile( src ); gi.WPrintf( "Compile failed.\n" ); throw "Error"; } gi.FS_FreeFile( src ); s_file = oldfile; }
void GetFileTask::onHttpRequestFinished() { if (canceled_) { return; } tmp_file_->close(); QString parent_dir = ::getParentPath(local_path_); if (!::createDirIfNotExists(parent_dir)) { setError(FileNetworkTask::FileIOError, tr("Failed to write file to disk")); emit finished(false); } QFile oldfile(local_path_); if (oldfile.exists() && !oldfile.remove()) { setError(FileNetworkTask::FileIOError, tr("Failed to remove the older version of the downloaded file")); emit finished(false); return; } if (!tmp_file_->rename(local_path_)) { setError(FileNetworkTask::FileIOError, tr("Failed to move file")); emit finished(false); return; } delete tmp_file_; tmp_file_ = 0; emit finished(true); }
/* delete user files */ int deluser(int uind) { char buf[60]; pcontext; #ifdef TRAFFICLOG /* close the trafficlog before deleting */ if(user(uind)->trafficlog!=NULL) { fclose(user(uind)->trafficlog); user(uind)->trafficlog=NULL; } #endif ap_snprintf(buf,sizeof(buf),lngtxt(380),uind); oldfile(buf); ap_snprintf(buf,sizeof(buf),lngtxt(381),uind); oldfile(buf); pcontext; ap_snprintf(buf,sizeof(buf),lngtxt(382),uind); clearsectionconfig(buf); flushconfig(); pcontext; return 0x0; }
int flushconfig() { FILE *handle; struct stringarray *wconf; pcontext; oldfile(configfile); handle=fopen(configfile,"w"); wconf=conf; while(wconf) { if(wconf->entry!=NULL) { if(strlen(wconf->entry)>1) fprintf(handle,"%s\n",wconf->entry); } wconf=wconf->next; } fclose(handle); return 0x0; }
bool DocumentEditor::rename(){ if(isModified()) { QMessageBox::warning(this, tr("Rename file"), tr("File %1 has unsaved modifications.\nSave it before rename it.\n").arg(getName()), QMessageBox::Ok); return false; } QString oldFileName = getName(); bool ok; QString file = QInputDialog::getText(this, tr("Rename"), tr("Rename %1 to").arg(oldFileName), QLineEdit::Normal, oldFileName, &ok); if(!ok) return false; QFile oldfile(getFullPath()); QString newfile = getPath() + QDir::separator() + file; _watcher.removePath(_fullPath); if(oldfile.rename(newfile)){ _fullPath = newfile; load(_fullPath); return true; }else{ _watcher.removePath(getFullPath()); QMessageBox::warning(this, tr("Rename file"), tr("Can't rename file %1.\n").arg(oldFileName), QMessageBox::Ok); return false; } }
int main (int argc, char **argv) { int rc; char *pt; char *bversion; FILE *pidfile,*conffile; if(argc==2) { strmncpy(configfile,argv[1],sizeof(configfile)); } else { strcpy(configfile,"psybnc.conf"); /* rcsid */ } conffile=fopen(configfile,"r"); if(conffile==NULL) { printf("Configuration File %s not found, aborting\nRun 'make menuconfig' for creating a configuration or create the file manually.\n",configfile); /* rcsid */ exit (0x0); } fclose(conffile); readconfig(); rc = getini("SYSTEM","LANGUAGE",INIFILE); /* rcsid */ if(rc!=0) { rc=loadlanguage("english"); /* rcsid */ } else { rc=loadlanguage(value); if(rc<0) rc=loadlanguage("english"); /* rcsid */ } if(rc<0) { printf("Could not load language file, aborting.\n"); /* rcsid */ exit(0x0); } printbanner(); printf(lngtxt(991),configfile); printf(lngtxt(992),langname); ap_snprintf(logfile,sizeof(logfile),lngtxt(993)); rc = getini(lngtxt(994),lngtxt(995),INIFILE); if (rc != 0) { printf("%s", lngtxt(996)); exit (0x0); } listenport = atoi(value); rc = getini(lngtxt(997),"ME",INIFILE); if (rc < 0) { memset(value,0x0,sizeof(value)); } pt=strchr(value,' '); /* shortening bouncername to no spaces */ if(pt) *pt=0; ap_snprintf(me,sizeof(me),"%s",value); rc = getini(lngtxt(998),lngtxt(999),INIFILE); if (rc < 0) { printf("%s", lngtxt(1000)); ap_snprintf(value,sizeof(value),lngtxt(1001)); } ap_snprintf(logfile,sizeof(logfile),"%s",value); oldfile(logfile); /* creating the socket-root */ socketnode=(struct socketnodes *) pmalloc(sizeof(struct usernodes)); socketnode->sock=NULL; socketnode->next=NULL; #ifdef IPV6 /* set the default ipv6 preference for users without a PREFERIPV6 setting */ rc = getini("SYSTEM", "DEFAULTIPV6", INIFILE); if (rc == 0) { defaultipv6 = atoi(value); } #endif /* creating the demon socket */ rc = createlisteners(); if (rc == 0) { printf("%s", lngtxt(1002)); exit (0x0); } /* creating background */ pidfile = fopen(lngtxt(1003),"w"); if(pidfile==NULL) { printf("%s", lngtxt(1004)); exit(0x0); } if(mainlog!=NULL) { fclose(mainlog); mainlog=NULL; } fflush(stdout); pid = fork(); //pid = 0; if (pid < 0) { } if (pid == 0) { rc= errorhandling(); makesalt(); #ifdef HAVE_SSL initSSL(); pcontext; #endif U_CREATE=0; #ifdef PARTYCHANNEL /* partychannel setup */ strmncpy(partytopic,lngtxt(1005),sizeof(partytopic)); partyusers=NULL; #endif /* creating the usernode-root */ usernode=(struct usernodes *) pmalloc(sizeof(struct usernodes)); usernode->uid=0; usernode->user=NULL; usernode->next=NULL; /* creating the newpeer-root */ peernode=(struct peernodes *) pmalloc(sizeof(struct peernodes)); peernode->uid=0; peernode->peer=NULL; peernode->next=NULL; /* creating the datalink-root */ linknode=(struct linknodes *) pmalloc(sizeof(struct linknodes)); linknode->uid=0; linknode->link=NULL; linknode->next=NULL; /* loading the users */ loadusers(); loadlinks(); pcontext; /* loading the hostallows */ hostallows=loadlist(lngtxt(1006),hostallows); } pcontext; if (pid) { bversion=buildversion(); printf(lngtxt(1007),bversion,pid); p_log(LOG_INFO,-1,lngtxt(1008),bversion,pid); fprintf( pidfile,"%d\n",pid); fclose(pidfile); exit (0x0); } pcontext; //#ifndef BLOCKDNS // if(init_dns_core()==0) // { // dns_err(0,1); // } //#endif p_dns_init(); bncmain(); return 0x0; }