Exemple #1
0
int main(int argc, char* argv[]){
	int n = argc - 3, i;
	char* files[n];

	if(argc < 4){
		printf("Input invalido: Esperado \"tempo palavra file1 ... fileN\" \n");
		return -1;
	}

	if( (tempo = parse_int(argv[1])) == LONG_MAX )
		return -1;

	char* palavra = argv[2];

	for(i = 0; i < n; i++){
		if( checkFile(argv[i+3]) == -1 )
			printf("O ficheiro %s nao existe \n", argv[i+3]);
		else{
			files[num_pids] = argv[i+3];
			num_pids++;
		}
	}

	if(num_pids == 0){
		printf("Nao encontrado nenhum ficheiro \n");
		return -1;
	}

	pids = malloc (sizeof(int) * num_pids);

	for (i = 0; i < num_pids; i++){
		if( (*(pids + i) = fork()) == -1 ){
				printf("Erro fork \n");
				return -1;
		}
		if(*(pids + i) == 0 ) /* FILHO */ {
			ficheiro(files[i], palavra);
			exit(0);
		}
	}
	
	if( (pidCheck = fork()) == -1 ){
		printf("Erro fork \n");
		exit(1);
	}

	if( pidCheck == 0)
		checkFiles(pids, files, num_pids);

	signal(SIGALRM, alarmhandler);
	signal(SIGINT, inthandler);
	alarm(tempo);
	
	int status;
	for(i = 0; i < num_pids; i++)
		wait(&status);

	return 0;
}
void WIZARD_FPLIB_TABLE::setupFileSelect()
{
    // Disable the button until something is selected
    enableNext( checkFiles() );

    // Clear the review list so it will be reloaded
    m_libraries.clear();
    m_listCtrlReview->DeleteAllItems();
}
Exemple #3
0
bool checkFiles(QList<QUrl> urls)
{
	QStringList files;

	for (int i = 0; i < urls.size(); i++)
		files.push_back(urls[i].toLocalFile());

	return checkFiles(files);
}
Exemple #4
0
FileWatcher::~FileWatcher()
{
	m_stateFlags |= Dying;
	this->stop();
	disconnect(m_watchTimer, SIGNAL(timeout()), this, SLOT(checkFiles()));
	if (!(m_stateFlags & AddRemoveBlocked))
		m_watchedFiles.clear();
	delete m_watchTimer;
}
Exemple #5
0
FileWatcher::FileWatcher( QObject* parent) : QObject(parent)
{
	m_stateFlags = 0;
	m_timeOut = 10000;
	m_watchedFiles.clear();
	m_watchTimer = new QTimer(this);
	m_watchTimer->setSingleShot(true);
	connect(m_watchTimer, SIGNAL(timeout()), this, SLOT(checkFiles()));
	m_watchTimer->start(m_timeOut);
}
Exemple #6
0
static long
dsoread(Chan *c, void *a, long n, vlong offset)
{
	MyFiles *f;
	char* s;

	if(c->qid.type == QTDIR)
		return devdirread(c, a, n, dsotab, nfichtab+2, devgen);

	if(c->qid.path == Qdata){
		//s = usage();  // Antes en lugar de los comando, mostraba la ayuda
		s = getComandos();
		return readstr(offset, a, n, s);
	}

	f = getMyFile(c);

	if(!f->valido || checkFiles(f) && (f->type != Qmir)){
		f->valido = 0;
		print("Fichero corrupto: %s\n",f->name);
	}

	// Se mantienen los cierres comentados
	// para indicar donde deben ir si fuesen necesarios

	if(!checkCorruptos(f)){
		//qlock(&f->lock); 

		switch(f->type){
			case Qcat:
				n = dsoconcatread(f, a, n, offset);
				break;
			case Qpar:
				n = dsopartread(f, a, n, offset);
				break;
			case Qmir:
				n = dsomirrorread(f, a, n,offset);
				break;
			case Qilv:
				n = dsointerlread(f, a, n, offset);
				break;
			default:
				print("BUG: f->type desconocido\n");
				n = 0;
		}

		//qunlock(&f->lock);
	}else{
		f->valido = 0;
		print("Imposible leer de %s\n",f->name);
		return 0;
	}

	return n;
}
Exemple #7
0
void PanoLastPage::initializePage()
{
    QString first = d->mngr->itemsList().first().fileName();
    QString last  = d->mngr->itemsList().last().fileName();
    QString file  = QString::fromLatin1("%1-%2")
        .arg(first.left(first.lastIndexOf(QLatin1Char('.'))))
        .arg(last.left(last.lastIndexOf(QLatin1Char('.'))));
    d->fileTemplateQLineEdit->setText(file);

    checkFiles();
}
Exemple #8
0
static void gbConfDump(FILE *fh, char *confFile, boolean defaulted,
                       boolean serverFileCheck, boolean clusterFileCheck,
                       boolean checkClusterMaster)
/* dump contents of genbank.conf file in different ways, including checking
 * for existence of certain files. */
{
struct gbConf *conf = gbConfNew(confFile);
if (serverFileCheck || clusterFileCheck  || checkClusterMaster)
    checkFiles(conf, serverFileCheck, clusterFileCheck, checkClusterMaster);
else if (defaulted)
    printGbConfDefaults(fh, conf);
else
    printGbConf(fh, conf);
gbConfFree(&conf);
}
std::string FileSystem::getFileList()
{
    std::stringstream ss;

    checkFiles();

    filesLock.lock();
    for (std::list<FileEntry>::iterator it=files.begin(); it != files.end(); ++it)
    {
        ss << (*it).filename << " " << (*it).key << std::endl;
    }
    filesLock.unlock();

    return ss.str();
}
void WIZARD_FPLIB_TABLE::OnSelectFiles( wxCommandEvent& aEvent )
{
    int filterIdx = m_filePicker->GetFilterIndex();

    if( m_selectedFilter != filterIdx )
    {
        m_selectedFilter = filterIdx;

        // Process the event again, as in the first iteration we cannot get the list of selected items
        wxCommandEvent ev( wxEVT_DIRCTRL_SELECTIONCHANGED );
        AddPendingEvent( ev );
        return;
    }

    enableNext( checkFiles() );
}
Exemple #11
0
void PanoLastPage::slotTemplateChanged(const QString&)
{
    d->title->setText(i18n("<qt>"
                           "<p><h1><b>Panorama Stitching is Done</b></h1></p>"
                           "<p>Congratulations. Your images are stitched into a panorama.</p>"
                           "<p>Your panorama will be created to the directory:<br />"
                           "<b>%1</b><br />"
                           "once you press the <i>Finish</i> button, with the name set below.</p>"
                           "<p>If you choose to save the project file, and "
                           "if your images were raw images then the converted images used during "
                           "the stitching process will be copied at the same time (those are "
                           "TIFF files that can be big).</p>"
                           "</qt>",
                           QDir::toNativeSeparators(d->mngr->preProcessedMap().begin().key().toString(QUrl::RemoveFilename | QUrl::PreferLocalFile))
                          ));
    checkFiles();
}
Exemple #12
0
int run_menuLoad()
{
	int end=0,c=0;

	if (text_dir_files==NULL)
		end=getDefaultFiles();
	else
		if (checkFiles())
			end=getDefaultFiles();

//	text_dir_num_files_index=0;

	raise_loadMenu();
	while(!end)
	{
		draw_loadMenu(c);
		end=key_loadMenu(&c);
	}
	unraise_loadMenu();

	return end;
}
/*
* Takes in the following parameters
* File - The file to en-/decode
* Key - file containing the key used for en-/decoding the file
*/
int main (int argc, char **argv) {
	
	// Check if the program was started with two parameters (file and key)
	if (argc == 3){
		FileContainer files;
		int securityDistance;
		
		if (checkFiles(argv) != 0) {
			files = openAndReadKey(argv[2]);
			char action = getUserInput();
			int choice = encodeOrDecode(action);

			switch (encodeOrDecode(action)) {
			case 0:
				printMessage(TYPE_INFO, CHOICE_EXIT);
				free(files.key);
				exit(0);
			case 1:
				securityDistance = getWantedSecLvl();
				
				printMessage(TYPE_INFO, INFO_ENCODING_START);
				encodeFile(files, argv[1], securityDistance);
				printMessage(TYPE_INFO, INFO_ENCODING_END);
				break;
			case 2:
				printMessage(TYPE_INFO, INFO_DECODING_START);
				decodeFile(files, argv[1]);
				printMessage(TYPE_INFO, INFO_DECODING_END);
				break;
			default:
				break;
			}
		}
	} else {
		printMessage(TYPE_ERROR, ERROR_PARAMETERS);
	}

	return 0;
}
Exemple #14
0
int KDEPrintd::print(const QString &cmd, const QStringList &files, bool remflag)
{
    KPrintProcess *proc = new KPrintProcess;
    QString command(cmd);
    QRegExp re("\\$out\\{([^}]*)\\}");

    connect(proc, SIGNAL(printTerminated(KPrintProcess *)), SLOT(slotPrintTerminated(KPrintProcess *)));
    connect(proc, SIGNAL(printError(KPrintProcess *, const QString &)), SLOT(slotPrintError(KPrintProcess *, const QString &)));
    proc->setCommand(command);
    if(re.search(command) != -1)
    {
        KURL url(re.cap(1));
        if(!url.isLocalFile())
        {
            QString tmpFilename = locateLocal("tmp", "kdeprint_" + kapp->randomString(8));
            command.replace(re, KProcess::quote(tmpFilename));
            proc->setOutput(re.cap(1));
            proc->setTempOutput(tmpFilename);
        }
        else
            command.replace(re, KProcess::quote(re.cap(1)));
    }

    if(checkFiles(command, files))
    {
        *proc << command;
        if(remflag)
            proc->setTempFiles(files);
        if(proc->print())
        {
            m_processpool.append(proc);
            return (int)proc->pid();
        }
    }

    delete proc;
    return -1;
}
Exemple #15
0
bool mtt::Torrent::start()
{
	if (state == State::DownloadUtm)
	{
		state = State::Started;
		return true;
	}

	if (!checking && !filesChecked())
	{
		checkFiles([this](std::shared_ptr<PiecesCheck> ch)
			{
				if (!ch->rejected)
					start();
			});
	}

	lastError = Status::E_InvalidInput;

	if (files.selection.files.empty())
		return false;

	lastError = files.prepareSelection();

	if (lastError != mtt::Status::Success)
		return false;

	service.start(2);

	state = State::Started;

	if (checking)
		return true;

	fileTransfer->start();

	return true;
}
MakeAtomDialog::MakeAtomDialog(MainWindow *parent) : QDialog(parent)
{
    ui.setupUi(this);

    mainWindow_ = parent;

    workingDir_ = mainWindow_->workingDir();

    //restrict what can be entered into each of the boxes
    QRegExp namerx("[A-Z][A-Za-z0-9]{2}");
    ui.nameLineEdit->setValidator(new QRegExpValidator(namerx, this));
    QRegExp numberrx("^\\d*\\.?\\d*$");
    ui.epsilonLineEdit->setValidator(new QRegExpValidator(numberrx, this));
    ui.sigmaLineEdit->setValidator(new QRegExpValidator(numberrx, this));
    ui.massLineEdit->setValidator(new QRegExpValidator(numberrx, this));
    QRegExp chargerx("^-?\\d*\\.?\\d*$");
    ui.chargeLineEdit->setValidator(new QRegExpValidator(chargerx, this));
    QRegExp symbolrx("[A-Z]{1}[a-z]?");
    ui.symbolLineEdit->setValidator(new QRegExpValidator(symbolrx, this));

    connect(ui.okButton, SIGNAL(clicked()), this, SLOT(checkFiles()));
    connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
Exemple #17
0
int
checkIndex(Disk &disk,char *attribute,block_run &run,bool collect)
{
	Directory *index = (Directory *)Inode::Factory(&disk,run);
	status_t status;
	if (index == NULL || (status = index->InitCheck()) < B_OK)
	{
		fprintf(stderr,"  Could not get index directory for \"%s\": %s!\n",attribute,index ? strerror(status) : "not found/corrupted");
		return -1;
	}

	printf("\nCheck \"%s\" index's on-disk structure...\n",attribute);
	//dump_inode(index->InodeBuffer());

	BPlusTree *tree;
	if (index->GetTree(&tree) < B_OK || tree->Validate(true) < B_OK)
	{
		fprintf(stderr,"  B+Tree of index \"%s\" seems to be corrupt!\n",attribute);
		//return -1;
	}

	if (collect && (!gDoNotCheckIndex || !gDoNotCheckForFiles))
		collectFiles(disk);

	if (!gDoNotCheckIndex)
	{
		printf("Check for non-existing files in index \"%s\"...\n",attribute);
		checkIndexForNonExistingFiles(disk,*tree);
	}

	if (!gDoNotCheckForFiles)
	{
		printf("Check for files not in index \"%s\" (this may take even more time)...\n",attribute);
		checkFiles(disk,*tree,attribute);
	}
	return 0;
}
Exemple #18
0
/// \brief Main program function
///
/// This function does very little on its own. It manages some output to
/// player's console, directs subsystems to initialize themselves and makes
/// choice of rendering engine. Then it runs the main game loop, processing
/// events and sending them further into the game.
int main(int argc, char *argv[])
{

    #if !defined(WIN32) && !defined(__APPLE__)
    #ifdef _GLIBCXX_DEBUG
	/*#if __WORDSIZE != 64*/

    /* Install our signal handler */
    struct sigaction sa;

    sa.sa_sigaction = /*(void *)*/crashhndl;
    sigemptyset (&sa.sa_mask);
    sa.sa_flags = SA_RESTART | SA_SIGINFO;

    sigaction(SIGSEGV, &sa, NULL);
    sigaction(SIGFPE, &sa, NULL);
    /*#endif*/
	#endif
    #endif



#ifdef WIN32
	WORD wVersionRequested;
	WSADATA wsaData;
	wVersionRequested = MAKEWORD( 2, 2 );

	if(WSAStartup(wVersionRequested, &wsaData) != 0){
		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Winsock startup failed!!");
		return -1;
	}

	if((LOBYTE(wsaData.wVersion) != 2) || (HIBYTE(wsaData.wVersion) != 2)){
		WSACleanup( );
		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "No Winsock 2.2 found!");
		return -1;
	}

#endif

	//setenv("SDL_VIDEODRIVER", "aalib", 0);
	//setenv("AAOPTS","-width 200 -height 70 -dim -reverse -bold -normal -boldfont  -eight -extended ",0);
	//setenv("AAFont","-*-fixed-bold-*-*-*-*-55-*-*-*-*-*-*",0);
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, PRODUCTLONG "\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "================================\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "version " PRODUCTVERSION "\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "compiled on " __DATE__ " " __TIME__ "\n");
#ifdef BUILDVERSION
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "build %s\n", BUILDVERSION);
#endif
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, " This is free software: you are free to change and redistribute it.\n"
		" There is NO WARRANTY, to the extent permitted by law. \n"
		" Review LICENSE in " PRODUCTSHORT " distribution for details.\n");


    yatc_fopen_init(argv[0]);



	options.Load();
	MAXFPS = options.maxfps;



#if HAVE_LIBINTL_H
    // set up i18n stuff
    if(options.lang.size())
    {
        std::string l("LANG=");
        l+=options.lang;
        putenv((char*)l.c_str());
    }
    setlocale( LC_ALL, "");//options.lang.c_str() );
    setlocale( LC_NUMERIC, "C");
    #if !BAZEL_BUILD
    bindtextdomain( "yatc", "./translations" );
    #else
    bindtextdomain( "yatc", (yatc_path_to_binary() + "yatc.runfiles/yatc/translations").c_str());
    #endif
    textdomain( "yatc" );
    bind_textdomain_codeset("yatc","windows-1252");
#endif

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Checking graphics files existence...\n");
	checkFiles();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "All graphics files were found.\n");


	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Initializing windowing...\n");

	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0){
		std::stringstream out;
		out << "Couldn't initialize SDL: " << SDL_GetError() << std::endl;
		DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, out.str().c_str());

		NativeGUIError(out.str().c_str(), PRODUCTSHORT " Fatal Error");
		exit(1);
	}

    // We are no longer dependant on .dat for this!
    // ivucica asks: nate, not dependant for what? why is this removed?
    // because of .ico? disagree.
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Loading data...\n");
	if(!Objects::getInstance()->loadDat("Tibia.dat")){
		DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, gettext("Loading data file failed!"));
		std::string forreplace = gettext("Loading the data file '$$FILENAME$$' has failed.\nPlease place '$$FILENAME$$' in the same folder as $$PRODUCTSHORT$$.\n");
		forreplace = str_replace("$$FILENAME$$", "Tibia.dat", forreplace);
		forreplace = str_replace("$$PRODUCTSHORT$$", PRODUCTSHORT, forreplace);
		NativeGUIError(forreplace.c_str(), str_replace("$$PRODUCTSHORT$$", PRODUCTSHORT, gettext("$$PRODUCTSHORT$$ Fatal Error")).c_str());
		exit(1);
	}


	setIcon(); // must be called prior to first call to SDL_SetVideoMode() (currently done in engine)

	SDL_EnableKeyRepeat(200, 50);
	SDL_EnableUNICODE(1);

	try{
	    g_engine = NULL; // set to null, in case anything that happens inside engine constructor wants to know we're just constructing
		switch(options.engine){
			#ifdef USE_OPENGL
			case ENGINE_OPENGL:
				g_engine = new EngineGL;
				break;
			#endif

			default:
				DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_WARNING, "Unknown engine was selected. Falling back to SDL.");
				options.engine = ENGINE_SDL;
			case ENGINE_SDL:
				g_engine = new EngineSDL;
				break;
		}

		if(!g_engine->isSupported()){
			DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_WARNING, "The selected graphics engine is not supported. Falling back to SDL.");
			delete g_engine;
			g_engine = NULL; // set to null, in case anything that happens inside engine constructor wants to know we're just constructing
			options.engine = ENGINE_SDL;
			g_engine = new EngineSDL;
		}

		// NOTE (nfries88): Make sure the window is sized as per the options
		int w = MAX(options.w, 656);
		int h = MAX(options.h, 352+options.consoleh);
		g_engine->doResize(w, h);


		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Loading skin...\n");
		g_skin.loadSkin();
		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Skin has been loaded\n");


		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Constructing gamemode...\n");
		resetDefaultCursor();
		if (argc == 1)
		{
		    g_game = new GM_MainMenu();
            //g_game = new GM_Debug(); // ivucica: this is for testing -- choice should be a cmd line option
		} else
		{
		    g_game = new GM_MainMenu();
            ProtocolGame* protocol = ProtocolConfig::createGameProtocol(854,"","","",false);
            g_connection = new ConnectionReplay(argv[1], protocol);
            if (argc==3)
            {
                sscanf(argv[2], "%f", &g_replayspeed);
            }

		}


        DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Initializing framerate manager...\n");
        SDL_initFramerate(&g_fpsmgr);
        SDL_setFramerate(&g_fpsmgr,MAXFPS);


		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Running\n");
        g_running = true;

        #ifdef WIN32
        SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
        #endif

		SDL_Event event;
		while(g_running){

            //g_engine->fpsMutexLock();

            //int beginticks = SDL_GetTicks();
            g_engine->performFpsCalc();

			//first process sdl events
			while(SDL_PollEvent(&event)){
				switch (event.type){
					case SDL_VIDEORESIZE:
						g_engine->doResize(event.resize.w, event.resize.h);
						g_game->doResize(event.resize.w, event.resize.h);
						break;

					case SDL_QUIT:
						g_game->onExitAttempt();
						break;

					case SDL_KEYDOWN:
						onKeyDown(event);
						break;
                    case SDL_KEYUP:
                        if((event.key.keysym.sym == SDLK_LSUPER)
                          || (event.key.keysym.sym == SDLK_RSUPER))
                            superkey_state = false;
                        break;

					case SDL_MOUSEBUTTONUP:
					case SDL_MOUSEBUTTONDOWN:
						#ifdef WINCE
						if (ptrx < 5 && ptry < 5)
							SDL_WM_IconifyWindow(); // appears to crash the application?! ah nevermind
						#endif
						g_game->mouseEvent(event);
						break;

					case SDL_MOUSEMOTION:
						ptrx = event.motion.x;
						ptry = event.motion.y;
						g_game->mouseEvent(event);
						break;
					default:
						break;
				}
			}
			//update current frame time
			g_frameDiff = SDL_GetTicks() - g_frameTime;
			g_frameTime = SDL_GetTicks();


            if (MAXFPS) {
                SDL_framerateDelay(&g_fpsmgr);

            }

			//check connection
			if(g_connection){
				g_connection->executeNetwork();
			}

            if (!(SDL_GetAppState() & SDL_APPACTIVE)) {// if the application is minimized
                #ifdef WIN32
                Sleep(100); // sleep a while, and don't paint
                #else
                usleep(100 * 1000);
                #endif
            } else { //otherwise update scene
                g_game->updateScene();
                g_engine->Flip();
            }
			g_frames ++;


			//g_engine->fpsMutexUnlock();

		}
	}
	catch(std::string errtext){
		DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, "%s", errtext.c_str());
	}

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Game over\n");

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Terminating protocol connection from main...\n");
	delete g_connection;
	g_connection = NULL;
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying map...\n");
	Map::getInstance().clear();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying creature cache...\n");
	Creatures::getInstance().clear();
	Creatures::destroyInstance();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying inventory...\n");
	Inventory::getInstance().clear();

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Unloading data...\n");
	Objects::getInstance()->unloadDat();
    Objects::destroyInstance();

    DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Unloading skin...\n");
	g_skin.unloadSkin();


	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Saving options...\n");
	options.Save();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Finishing engine...\n");
	delete g_engine;
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Ending game...\n");
	delete g_game;
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Shutting down SDL...\n");
	SDL_Quit();

#ifdef WIN32
	WSACleanup();
#endif

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Thanks for playing!\n");

	return 0;
}
Exemple #19
0
static long
dsowrite(Chan *c, void *a, long n, vlong offset)
{
	MyFiles *f;
	char *b = a;
	int i;
	char *line = (char*)malloc(n+1);
	char* cmd = nil;
	char *args[ARGSMAX];
	int nargs;
	long r = 0;

	for(i = 0; i < n; i++){
		line[i] = b[i];
	}

	line[n] = '\0';

	if(c->qid.type == QTDIR){
		error(Eperm);
	}

	if(c->qid.path == Qdata){
		kstrdup(&cmd,line);
		nargs = tokenize(line, args, ARGSMAX+1);
		if(nargs == ARGSMAX)
			print("Solo se consideraran %d argumentos\n",ARGSMAX);
		r = dsoaction(args,nargs);

		if(r >= 0){
			addCommand(cmd);
			return n;
		}

		return -1;
	}

	f = getMyFile(c);

	if(checkCorruptos(f))
		f->valido = 0;

	// Como en lectura, conservamos los cierres comentados
	// y ademas, las llamadas a setSize
	if(f->valido && !checkFiles(f) || (f->type == Qmir)){

		//qlock(&f->lock);

		switch(f->type){
			case Qcat:
				r = dsoconcatwrite(f, a, n, offset);
				//setSize(c);
				break;
			case Qpar:
				r = dsopartwrite(f, a, n, offset);
				break;
			case Qmir:
				r = dsomirrorwrite(f, a, n, offset);
				//setSize(c);
				break;
			case Qilv:
				r = dsointerlwrite(f, a, n, offset);
				//setSize(c);
				break;
			default:
				print("BUG_WRITE: f->type desconocido\n");
				r = -1;
		}

		//qunlock(&f->lock);

	}else{
		//qlock(&f->lock);
		f->valido = 0;
		print("Fichero corrupto: %s\n",f->name);
		//qunlock(&f->lock);
		error("#Q: El fichero esta corrupto");
	}

	return r;
}
Exemple #20
0
void FileWatcher::forceScan()
{
	checkFiles();
}
Exemple #21
0
//checks local files. returns true if they are good false if they are bad
bool UMcf::checkFiles()
{
    return checkFiles(nullptr);
}
Exemple #22
0
void PanoLastPage::slotPtoCheckBoxChanged(int)
{
    checkFiles();
}
Exemple #23
0
void mtt::Torrent::checkFiles()
{
	checkFiles([](std::shared_ptr<PiecesCheck>) {});
}
//--------------------------------------------------------------
void handleChapters::readDir(){
    
    printf("reading directory sir\n");
    
    // load content
    dir.listDir("content/");
	dir.sort(); // in linux the file system doesn't return file lists ordered in alphabetical order
    
	//allocate the vector to have as many strings as files
	if( dir.size() ){
		chapters.assign(dir.size(), Chapters());
	}
    
	// you can now iterate through the files and load them into the Chapters vector
	for(int i = 0; i < (int)dir.size(); i++){
        
        file.open(dir.getPath(i));
        if(file.isDirectory()){
            dir.sort(); // do this again to alfabetize
            
            chapters[i].complete = false; // don't worry kids, we're just not certain yet
            chapters[i].inOrder  = false; // let me get back to that
            
            chapters[i].name = dir.getName(i);
            printf("%s\n",chapters[i].name.c_str());
            // getting filename should be a folder
            
            
            // write a new chapter to the XMl object
            if( XML.pushTag("movies", lastTagNumber) ){
                
                dir.listDir(dir.getPath(i)+"/");
                dir.sort();
                
                int lastChapNumber = XML.addTag("chapter");
                // writing chapter folder name to XML object
                XML.setValue("chapter:name", chapters[i].name, lastChapNumber);
                
                //printf("tagNum: %i\n",lastChapNumber);
                //printf("lastTagNumber: %i\n",lastTagNumber);
                
                // iterate through directory
                for(int f = 0; f < (int)dir.size(); f++){
                    file.open(dir.getPath(f));
                    
                    printf("iterating through directory %i\n",f);
                    
                    if(file.isFile()){
                        file.open(dir.getPath(f));
                        
                        // check if movie is named L, M or R then add to filmInfo object thats inside Chapters
                        // furthermore we check for several aspects of the film files, some info is only gained
                        // when actually loading the video, so thats where the tempMov kicks in. This is a bit
                        // processor heavy though, so do't do it all the time!
                        string baseName = file.getBaseName();
                        string firstChar = "";
                        firstChar += baseName[0];
                        
                        printf("filename: %s\n", dir.getName(f).c_str());
                        
                        if(firstChar == "L"){ // left screen duh
                            chapters[i].left.file = dir.getPath(f);
                            chapters[i].left.name = dir.getName(f);
                            chapters[i].left.filesize = file.getSize();
                            
                            ofVideoPlayer vid;
                            videos.push_back(vid);
                            
                            if (videos.back().loadMovie(chapters[i].left.file)) {
                                chapters[i].left.width     = videos.back().getWidth();
                                chapters[i].left.height    = videos.back().getHeight();
                                chapters[i].left.duration  = videos.back().getDuration();
                                chapters[i].left.numFrames = videos.back().getTotalNumFrames();
                            }
                            
                            chapters[i].left.sameSettings = false; // figure this out later
                            
                            if( XML.pushTag("chapter", lastChapNumber) ){
                                int tagNum = XML.addTag("left");
                                // writing film info of this thing to XML
                                XML.setValue("left:file", chapters[i].left.file, tagNum);
                                XML.setValue("left:name", chapters[i].left.name, tagNum);
                                XML.setValue("left:duration", chapters[i].left.duration, tagNum);
                                XML.setValue("left:frames", chapters[i].left.numFrames, tagNum);
                                XML.setValue("left:filesize", chapters[i].left.filesize, tagNum);
                                XML.setValue("left:width", chapters[i].left.width, tagNum);
                                XML.setValue("left:height", chapters[i].left.height, tagNum);
                                XML.popTag();
                            }
                        } else if(firstChar == "M"){ // middle screen duh
                            chapters[i].middle.file = dir.getPath(f);
                            chapters[i].middle.name = dir.getName(f);
                            chapters[i].middle.filesize = file.getSize();
                            
                            ofVideoPlayer vid;
                            videos.push_back(vid);
                            
                            if (videos.back().loadMovie(chapters[i].middle.file)) {
                                chapters[i].middle.width     = videos.back().getWidth();
                                chapters[i].middle.height    = videos.back().getHeight();
                                chapters[i].middle.duration  = videos.back().getDuration();
                                chapters[i].middle.numFrames = videos.back().getTotalNumFrames();
                            }
                            
                            chapters[i].middle.sameSettings = false; // figure this out later
                            
                            if( XML.pushTag("chapter", lastChapNumber) ){
                                int tagNum = XML.addTag("middle");
                                // writing film info of this thing to XML
                                XML.setValue("middle:file", chapters[i].middle.file, tagNum);
                                XML.setValue("middle:name", chapters[i].middle.name, tagNum);
                                XML.setValue("middle:duration", chapters[i].middle.duration, tagNum);
                                XML.setValue("middle:frames", chapters[i].left.numFrames, tagNum);
                                XML.setValue("middle:filesize", chapters[i].middle.filesize, tagNum);
                                XML.setValue("middle:width", chapters[i].middle.width, tagNum);
                                XML.setValue("middle:height", chapters[i].middle.height, tagNum);
                                XML.popTag();
                            }
                        } else if(firstChar == "R"){ // right screen duh
                            chapters[i].right.file = dir.getPath(f);
                            chapters[i].right.name = dir.getName(f);
                            chapters[i].right.filesize = file.getSize();
                            
                            ofVideoPlayer vid;
                            videos.push_back(vid);
                            
                            if (videos.back().loadMovie(chapters[i].right.file)) {
                                chapters[i].right.width     = videos.back().getWidth();
                                chapters[i].right.height    = videos.back().getHeight();
                                chapters[i].right.duration  = videos.back().getDuration();
                                chapters[i].right.numFrames = videos.back().getTotalNumFrames();
                            }
                            
                            chapters[i].right.sameSettings = false; // figure this out later
                            
                            if( XML.pushTag("chapter", lastChapNumber) ){
                                int tagNum = XML.addTag("right");
                                // writing film info of this thing to XML
                                XML.setValue("right:file", chapters[i].right.file, tagNum);
                                XML.setValue("right:name", chapters[i].right.name, tagNum);
                                XML.setValue("right:duration", chapters[i].right.duration, tagNum);
                                XML.setValue("right:frames", chapters[i].left.numFrames, tagNum);
                                XML.setValue("right:filesize", chapters[i].right.filesize, tagNum);
                                XML.setValue("right:width", chapters[i].right.width, tagNum);
                                XML.setValue("right:height", chapters[i].right.height, tagNum);
                                XML.popTag();
                            }
                        }
                    }
                }
                dir.listDir("content/");
                dir.sort();
                // pop out of chapter
                XML.popTag();
            }
            
        } else {
            printf("no directory senior! - %s\n", dir.getPath(i).c_str());
        }
    }
    checkFiles(); // checking to see if all files are in order
    writeXML(); // write it to an XML file, makes it easy to check whats wrong
    
    // chopping up the xml file into 300 char pieces so I can send it over the MPE network for checking
    XML.copyXmlToString(totalXmlString);
    totalXmlString.erase(std::remove(totalXmlString.begin(), totalXmlString.end(), '\n'), totalXmlString.end());
    totalXmlString.erase(std::remove(totalXmlString.begin(), totalXmlString.end(), ' '), totalXmlString.end());
    totalXmlString.erase(std::remove(totalXmlString.begin(), totalXmlString.end(), ','), totalXmlString.end());
    int chopLength = 300;
    float fChops = float(totalXmlString.size())/float(chopLength);
    float fChopsRoundUP = ceil(fChops);
    int numChops = int(fChopsRoundUP);
    partXML.resize(numChops);
    for (int i = 0; i < numChops; i++) {
        partXML[i].part = totalXmlString.substr(i*chopLength,chopLength);
        partXML[i].checked = false;
    }
    
    // deleting the videoplayer instances we just used

    
    for (int i = 0; i < videos.size(); i++) {
        videos[i].close();
    }
    videos.erase(videos.begin(), videos.end());
    
}