/*! Returns the file associated with the AppLnk. \sa exec() name() */ QString AppLnk::file() const { if ( mExec.isEmpty ( ) && mFile.isNull() ) { AppLnk* that = (AppLnk*)this; QString ext = MimeType(mType).extension(); if ( !ext.isEmpty() ) ext = "." + ext; if ( !mLinkFile.isEmpty() ) { that->mFile = mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; qDebug("mFile now == %s", mFile.latin1()); } else if ( mType.contains('/') ) { that->mFile = QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); /* * A file with the same name or a .desktop file already exists */ if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { int n=1; QString nn; while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) || QFile::exists(nn+".desktop")) n++; that->mFile = nn; } that->mLinkFile = that->mFile+".desktop"; that->mFile += ext; } prepareDirectories(that->mFile); if ( !that->mFile.isEmpty() ) { QFile f(that->mFile); if ( !f.open(IO_WriteOnly) ) that->mFile = QString::null; return that->mFile; } } return mFile; }
int main( int argc , char **argv ) { parseOpts( argc, argv ); // Nuke +1 1012: Loop counter int counter1 = 0; int counter2 = 0; int counter3 = 0; int counter4 = 0; signal(SIGUSR1, sigusr1); log_rotate_interval = 3600 * 24 * 7; Lock_Init(); // Arminius 7.17 memory lock UNlockM_Init(); if(readConfig( "acserv.cf" )<0){ log( "ÎÞ·¨ÔÚµ±Ç°Ä¿Â¼Àï¶ÁÈ¡ acserv.cf .\n" ); exit(1); } #ifdef _SASQL sasql_init(); #endif log( "¶ÁÈ¡Êý¾ÝĿ¼\n" ); dbRead( dbdir ); #ifdef _FAMILY log("¶ÁÈ¡ ¼Ò×åׯ԰\n"); readFMSMemo(fmsmemodir); log("¶ÁÈ¡ ¼Ò×åÁôÑÔ\n"); readFMPoint(fmpointdir); log("¶ÁÈ¡ ¼Ò×åĿ¼\n"); readFamily(familydir); #endif log( "×¼±¸ µµ°¸Ä¿Â¼\n" ); prepareDirectories( chardir ); log( "×¼±¸ ÈÕ־Ŀ¼\n" ); prepareDirectories( logdir ); log( "×¼±¸ ÓʼþĿ¼\n" ); prepareDirectories( maildir ); #ifdef _SLEEP_CHAR prepareDirectories( sleepchardir ); log( "×¼±¸ ˯Ãßµµ°¸Ä¿Â¼\n" ); #endif /* Ð×ÒýÔÈ»¯Ô¶ª¡õ»ïë Ðijð¸ê */ if( readMail(maildir) < 0 ){ log( "²»Äܳõʼ»¯Óʼþ\n" ); exit(1); } /* TCPSTRUCT ëâÙÓå¼À */ { int tcpr; if( ( tcpr = tcpstruct_init( NULL , port , 0 , CHARDATASIZE * 16 * MAXCONNECTION , 1 /* DEBUG */ ) ) < 0 ){ log( "²»ÄÜ¿ªÆôTCP: %d\n", tcpr ); return 1; } } saacproto_InitServer( netWrite , CHARDATASIZE ); { struct sigaction s,os; bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGTERM, &s, &os ); bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGINT, &s, &os ); bzero( &s, sizeof( s )); s.sa_handler = SIG_IGN; s.sa_flags = SA_NOMASK; sigaction( SIGPIPE, &s, &os ); } #ifdef _AC_SEND_FM_PK // WON ADD ׯ԰¶ÔÕ½ÁÐ±í´¢´æÔÚAC load_fm_pk_list(); #endif #ifdef _ACFMPK_LIST FMPK_LoadList(); #endif #ifdef _ALLDOMAN LOAD_herolist(); // Syu ADD ÅÅÐаñNPC #endif #ifdef _ANGEL_SUMMON initMissionTable(); #endif #ifdef _VIP log( "\n·þÎñ¶Ë°æ±¾: <%s »áÔ±°æ>\n" , SERVER_VERSION ); #else log( "\n·þÎñ¶Ë°æ±¾: <%s ÆÕͨ°æ>\n" , SERVER_VERSION ); #endif log( "\n·þÎñ¶Ë±àÒëÍê³Éʱ¼ä:%s %s by 17CSA¹¤×÷ÊÒ\n" , __DATE__ , __TIME__ ); log( "\n¿ªÊ¼¹¤×÷...\n" ); signal(SIGUSR1,sigusr1); // Arminius 7.20 memory lock int itime=0; while(1){ itime++; if(itime>cpuuse){ itime=0; usleep(1); } int newti,i; static time_t main_loop_time; sys_time = time(NULL); if( main_loop_time != sys_time){ main_loop_time = time(NULL); counter1++; counter2++; counter3++; counter4++; //andy add 2002/06/20 UNlockM_UnlockPlayer(); #ifdef _ANGEL_SUMMON checkMissionTimelimit(); #endif // Nuke *1 1012 if( counter1 > Total_Charlist ){ counter1=0; char *c = ctime( &main_loop_time ); if( c ){ struct timeval st,et; log( "\nTIME:%s\n",c ); gettimeofday( &st,NULL); dbFlush(dbdir); gettimeofday( &et,NULL); log( "Flushed db(%fsec)\n", time_diff(et,st) ); log( "µµ°¸±íÁÐ×ÜÊý:%d NG:%d\n", total_ok_charlist, total_ng_charlist ); } } // Nuke **1 1012 //if( ( counter % 600 ) == 0 ){ if( counter2 > Expired_mail ){ counter2=0; struct timeval st,et; gettimeofday( &st,NULL); expireMail(); gettimeofday( &et,NULL); log( "¹ýÆÚÓʼþ(%fsec)\n", time_diff(et,st) ); } #ifdef _FAMILY //if ((counter % 300) == 0) // 300( -> 60) if( counter4 > Write_Family ) // 300( -> 60) { counter4=0; struct timeval st, et; gettimeofday(&st, NULL); writeFamily(familydir); writeFMPoint(fmpointdir); writeFMSMemo(fmsmemodir); gettimeofday(&et, NULL); log("¼Ç¼¼Ò×å(%fsec)\n", time_diff(et, st)); } #endif } newti = tcpstruct_accept1(); if( newti >= 0 ){ log( "ͬÒâ: %d\n" , newti ); gs[newti].use = 1; } for(i=0;i<MAXCONNECTION;i++){ // char buf[CHARDATASIZE * 16; char buf[CHARDATASIZE]; int l; l = tcpstruct_readline_chop( i , buf , sizeof( buf )- 1); { if( !gs[i].use )continue; if( l > 0 ){ char debugfun[256]; buf[l]=0; if( saacproto_ServerDispatchMessage( i , buf, debugfun)<0){ // Nuke start //tcpstruct_close(i);// avoid the shutdown the gmsv ttom log( "GMSV(%s) ÏûÏ¢:%s\n", gs[i].name, debugfun); FILE *fp; if( (fp=fopen( "badgmsv.txt", "a+")) != NULL ){ fprintf( fp, "GMSV(%s) ÏûÏ¢:%s\n", gs[i].name, debugfun); fclose( fp); } } } else if( l == TCPSTRUCT_ETOOLONG ){ log( "ºÜ³¤:%d ·þÎñÆ÷Ãû::%s\n", i , gs[i].name ); FILE *fp; if( (fp=fopen( "badgmsv.txt", "a+")) != NULL ){ fprintf( fp, "ºÜ³¤:%d ·þÎñÆ÷Ãû::%s\n", i , gs[i].name); fclose( fp); } logout_game_server( i ); } else if( l < 0 ){ log( "¹Ø±Õ:%d ·þÎñÆ÷Ãû:%s\n", i , gs[i].name ); FILE *fp; if( (fp=fopen( "badgmsv.txt", "a+")) != NULL ){ fprintf( fp, "¹Ø±Õ:%d ·þÎñÆ÷Ãû:%s\n", i , gs[i].name); fclose( fp); } logout_game_server(i); } else if( l == 0 ){ ; } } } { static struct timeval tv_loop_store ; struct timeval now; double dif; gettimeofday( &now , NULL ); dif = time_diff( now, tv_loop_store ); if( dif > 0.5 ){ // CoolFish 0.1 -> 0.5 2001/5/19 //log( "Sl:%f" , dif ); } tv_loop_store = now; } /* ·¥¡õÊСõ¼°ÕýÄÌةʧËüÐþëƩÍÍÔÂ£Û ÕýÄÌةʧËüÐþØÆÐ×ÈÕ·òºëë·ÖØÆ»¯·¥¡õÊСõëڽØÆ»¯ØÆÒýµ¤£Û Æ¥±Ø¡õØ©ÈÓ¡õÌï¡õ±å ±Î¶Á±å·´É§ôÅÔÊÔ */ } return 0; }
int main( int argc , char **argv ) { parseOpts( argc, argv ); // Nuke +1 1012: Loop counter int counter1 = 0; int counter2 = 0; int counter3 = 0; int counter4 = 0; signal(SIGUSR1, sigusr1); log_rotate_interval = 3600 * 24 * 7; Lock_Init(); // Arminius 7.17 memory lock UNlockM_Init(); if(readConfig( "acserv.cf" )<0){ log( "���ڵ�ǰĿ¼���ȡ acserv.cf .\n" ); exit(1); } #ifdef _SASQL sasql_init(); #endif log( "��ȡ����Ŀ¼\n" ); dbRead( dbdir ); #ifdef _FAMILY log("��ȡ ����ׯ\n"); readFMSMemo(fmsmemodir); log("��ȡ ��������\n"); readFMPoint(fmpointdir); log("��ȡ ����Ŀ¼\n"); readFamily(familydir); #endif log( "�� ����Ŀ¼\n" ); prepareDirectories( chardir ); log( "�� ��־Ŀ¼\n" ); prepareDirectories( logdir ); log( "�� �ʼ�Ŀ¼\n" ); prepareDirectories( maildir ); #ifdef _SLEEP_CHAR prepareDirectories( sleepchardir ); log( "�� ˯�ߵ���Ŀ¼\n" ); #endif /* �����Ȼ��¶�����ë �ij�� */ if( readMail(maildir) < 0 ){ log( "���ܳ�ʼ���ʼ�\n" ); exit(1); } /* TCPSTRUCT ë����� */ { int tcpr; if( ( tcpr = tcpstruct_init( NULL , port , 0 , CHARDATASIZE * 16 * MAXCONNECTION , 1 /* DEBUG */ ) ) < 0 ){ log( "���ܿ���TCP: %d\n", tcpr ); return 1; } } saacproto_InitServer( netWrite , CHARDATASIZE ); { struct sigaction s,os; bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGTERM, &s, &os ); bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGINT, &s, &os ); bzero( &s, sizeof( s )); s.sa_handler = SIG_IGN; s.sa_flags = SA_NOMASK; sigaction( SIGPIPE, &s, &os ); } #ifdef _AC_SEND_FM_PK // WON ADD ׯ��ս�б�����AC load_fm_pk_list(); #endif #ifdef _ACFMPK_LIST FMPK_LoadList(); #endif #ifdef _ALLDOMAN LOAD_herolist(); // Syu ADD ���а�NPC #endif #ifdef _VIP log( "\n����˰汾: <%s ��Ա��>\n" , SERVER_VERSION ); #else log( "\n����˰汾: <%s ��ͨ��>\n" , SERVER_VERSION ); #endif log( "\n����˱������ʱ��:%s %s by ��zoro������\n" , __DATE__ , __TIME__ ); log( "\n��ʼ����...\n" ); signal(SIGUSR1,sigusr1); // Arminius 7.20 memory lock int itime=0; while(1){ itime++; if(itime>cpuuse){ itime=0; usleep(1); } int newti,i; static time_t main_loop_time; sys_time = time(NULL); if( main_loop_time != sys_time){ main_loop_time = time(NULL); counter1++; counter2++; counter3++; counter4++; //andy add 2002/06/20 UNlockM_UnlockPlayer(); #ifdef _ANGEL_SUMMON checkMissionTimelimit(); #endif // Nuke *1 1012 if( counter1 > Total_Charlist ){ counter1=0; char *c = ctime( &main_loop_time ); if( c ){ struct timeval st,et; log( "\nTIME:%s\n",c ); gettimeofday( &st,NULL); dbFlush(dbdir); gettimeofday( &et,NULL); log( "Flushed db(%fsec)\n", time_diff(et,st) ); log( "������������:%d NG:%d\n", total_ok_charlist, total_ng_charlist ); } } // Nuke **1 1012 //if( ( counter % 600 ) == 0 ){ if( counter2 > Expired_mail ){ counter2=0; struct timeval st,et; gettimeofday( &st,NULL); expireMail(); gettimeofday( &et,NULL); log( "�����ʼ�(%fsec)\n", time_diff(et,st) ); } #ifdef _FAMILY //if ((counter % 300) == 0) // 300( -> 60) if( counter4 > Write_Family ) // 300( -> 60) { counter4=0; struct timeval st, et; gettimeofday(&st, NULL); writeFamily(familydir); writeFMPoint(fmpointdir); writeFMSMemo(fmsmemodir); gettimeofday(&et, NULL); log("��¼����(%fsec)\n", time_diff(et, st)); } #endif } newti = tcpstruct_accept1(); if( newti >= 0 ){ log( "ͬ��: %d\n" , newti ); gs[newti].use = 1; } for(i=0;i<MAXCONNECTION;i++){ // char buf[CHARDATASIZE * 16; char buf[CHARDATASIZE]; int l; l = tcpstruct_readline_chop( i , buf , sizeof( buf )- 1); { if( !gs[i].use )continue; if( l > 0 ){ char debugfun[256]; buf[l]=0; if( saacproto_ServerDispatchMessage( i , buf, debugfun)<0){ // Nuke start tcpstruct_close(i);// avoid the shutdown the gmsv ttom log( "GMSV(%s) ��Ϣ:%s\n", gs[i].name, debugfun); } } else if( l == TCPSTRUCT_ETOOLONG ){ log( "�ܳ�:%d ��������::%s\n", i , gs[i].name ); logout_game_server( i ); } else if( l < 0 ){ log( "�ر�:%d ��������:%s\n", i , gs[i].name ); logout_game_server(i); } else if( l == 0 ){ ; } } } { static struct timeval tv_loop_store ; struct timeval now; double dif; gettimeofday( &now , NULL ); dif = time_diff( now, tv_loop_store ); if( dif > 0.5 ){ // CoolFish 0.1 -> 0.5 2001/5/19 //log( "Sl:%f" , dif ); } tv_loop_store = now; } /* �����С�������ةʧ����ëƩ���£� ����ةʧ���������շ��ë���ƻ������С�ëڽ�ƻ��������� ƥ�ء�ة�ӡ������ �ζ��巴ɧ������ */ } return 0; }
File* ZipArchive::extractFile(const std::string& fileName, const ZipArchive::ArchiveTarget target, const std::string& targetDirectory, const bool keepDirectoryStructure, const bool replaceExistingFile) { ArchiveMap::iterator it = files_.find(fileName); if (it == files_.end()) { LERROR("extractFile(): there is no such file named '" << fileName << "' to extract!"); return 0; } ArchivedFile& af = it->second; if (af.isNewInArchive_ == true) { LERROR("extractFile(): the file '" << fileName << "' has just been added to the archive"); LERROR(" and cannot be extracted, because the archive has not been saved yet. Call save() first."); return 0; } if (readLocalFileHeader(af.zipLocalFileHeader_, af.localHeaderOffset_) == false) { LERROR("extractFile(): could not read LocalFileHeader for file '" << fileName << "'!"); return 0; } ZipLocalFileHeader& lfh = af.zipLocalFileHeader_; size_t bufferSize = (lfh.compressionMethod == 0) ? lfh.uncompressedSize : lfh.compressedSize; if (bufferSize == 0) { LERROR("File size of '" << af.fileName_ << "' is 0."); return 0; } if (lfh.generalPurposeFlag != 0x0000) { LERROR("The file " << af.fileName_ << " seems to make " << "use of advanced features this reader cannot deal with"); return 0; } size_t fileOffset = (af.localHeaderOffset_ + SIZE_ZIPLOCALFILEHEADER + lfh.filenameLength + lfh.extraFieldLength); std::string zipFileName = ((keepDirectoryStructure == true) ? af.fileName_ : FileSystem::fileName(af.fileName_)); if (targetDirectory.empty() == false) { if (targetDirectory[targetDirectory.size() - 1] != '/') zipFileName = targetDirectory + "/" + zipFileName; else zipFileName = targetDirectory + zipFileName; } LINFO("Extracting file " << af.fileName_ << " to " << zipFileName); if (FileSystem::fileExists(zipFileName)) { if (replaceExistingFile) { LWARNING("Overwriting existing file " << zipFileName); } else { LERROR("File " << zipFileName << " already exists"); return 0; } } if ((keepDirectoryStructure == true) && (prepareDirectories(af.fileName_) == false)) { LERROR("Failed to prepare directroy structure"); return 0; } switch (lfh.compressionMethod) { case 0: LDEBUG("compression method: archive (no compression)"); switch (target) { case TARGET_DISK: return extractUncompressedToDisk(zipFileName, lfh.uncompressedSize, fileOffset); case TARGET_MEMORY: return extractUncompressedToMemory(zipFileName, lfh.uncompressedSize, fileOffset); } break; case 8: LDEBUG("compression method: deflate"); switch (target) { case TARGET_DISK: return inflateToDisk(zipFileName, lfh.compressedSize, lfh.uncompressedSize, fileOffset); case TARGET_MEMORY: return inflateToMemory(zipFileName, lfh.compressedSize, lfh.uncompressedSize, fileOffset); } break; default: LERROR("unsupported compression method (code = " << lfh.compressionMethod << ")!"); LERROR("This archiver currently supports only method 'deflate' and 'uncompressed'."); break; } return 0; }
/*! Attempts to ensure that the link file for this AppLnk exists, including creating any required directories. Returns TRUE if successful; otherwise returns FALSE. You should not need to use this function. */ bool AppLnk::ensureLinkExists() const { QString lf = linkFile(); return prepareDirectories(lf); }