예제 #1
0
void execute_file_menu(int choice,const char * choice_name, char * folder){
    char file[strlen(choice_name)];
    char folder_complet[strlen(folder)+strlen(file)+1];
    
    strcpy(file, choice_name);
    
    strcpy(folder_complet, folder);
    strcat(folder_complet, file);
    
    
    if(exists(folder_complet) == 1){
         
         mvprintw(LINES-2, 0, "                                                        ");
         mvprintw(LINES-1, 0, "%s                                                                ", folder_complet);
         display_execution(6, mem, taille_mem, reg, taille_reg, 1, 2, 3);
        
    }
    else if(exists(folder_complet) == 2){
        strcat(folder_complet, "/");
        int i;
        char ** files = list_file(folder_complet, &i);
        mvprintw(LINES-1, 0, "Dossier:  %s                                                        ", folder_complet);
        draw_menu(files, execute_file_menu, folder_complet, i);
    }
    else{
        mvprintw(LINES-1, 0, "Une erreur s'est produite lors de l'ouverture du fichier. Retour à ./");
        int i;
        char ** files = list_file("", &i);
        draw_menu(files, execute_file_menu, "", i);
    }

}
예제 #2
0
/* log some event into the log list */
void log_event(int time, int event_type, int taxi_state, int plane_id, bool storm, int berth_number) {
    transfer[1] = time;
    transfer[2] = event_type;
    transfer[3] = taxi_state;
    transfer[4] = plane_id;
    transfer[5] = storm;
    transfer[6] = berth_number;
    transfer[7] = list_size[LIST_RUNWAY];
    transfer[8] = check_num_berths_finished();

    /* Add attributes in transfer to log list */
    if (list_size[LIST_LOG] == 0) {
        list_file(FIRST, LIST_LOG);
    }
    else {
        list_file(INCREASING, LIST_LOG);
    }

    /*
    float ftime = (float)time/60;
    char *event = strings_event[event_type];
    char *taxi = strings_taxi[taxi_state];
    //int plane_id = transfer[PLANE_ID];
    char *cstorm = strings_storm[storm_state];
    //int berth_number = transfer[BERTH_NUMBER];

    printf("Time: %06.1f  Event: %s  Taxi: %s  Plane id: %03d   Storm %s   Berth: %d\n",
            ftime, event, taxi, plane_id, cstorm, berth_number);
    */

}
예제 #3
0
파일: ls.c 프로젝트: hoangt/vmwos
int ls(char *path) {

	int fd,result;
	char buf[BUF_SIZE];
	int nread;
	int offset;
	struct vmwos_dirent *d;
	struct stat stat_buf;

	result=stat(path,&stat_buf);
	if (result<0) {
		printf("Cannot access %s: no such file or directory!\n",path);
		return -1;
	}

//	printf("Mode: %x\n",stat_buf.st_mode);

	/* handle if it's not a directory */
	if ( (stat_buf.st_mode&S_IFMT)!=S_IFDIR) {
		list_file(path);
		return 0;
	}

	/* handle if it's a directory */
	fd=open(path,O_RDONLY,0);
	if (fd<0) {
		printf("Error! %s\n",strerror(errno));
	}

	while(1) {
		nread = getdents (fd, (struct vmwos_dirent *)buf, BUF_SIZE);
		if (nread<0) {
			printf("Error! %s\n",strerror(errno));
			break;
		}
		if (nread==0) break;

		offset=0;
		while(offset<nread) {
			d=(struct vmwos_dirent *)(buf+offset);
//			printf("Inode: %ld\n",d->d_ino);
			list_file(d->d_name);
			offset+=d->d_reclen;
		}
	}


	close(fd);


	return 0;
}
예제 #4
0
/*
 * Counts the contents of an SRF file.
 * If the hash index exists it uses this instead.
 *
 * Returns num_reads for success
 *        -1 for failure
 */
int64_t count_file(char *fname, opts *opts) {
    srf_t *srf;
    srf_index_hdr_t hdr;
    off_t ipos, skip;
    int item_sz = 9;

    if (NULL == (srf = srf_open(fname, "r"))) {
	perror(fname);
	return -1;
    }

    /* Read the index header */
    if (0 != srf_read_index_hdr(srf, &hdr, 0)) {
	srf_destroy(srf, 1);
	return list_file(fname, opts);
    }
    ipos = ftello(srf->fp);

    /* Compute the remaining size of the index and divide by item_sz */
    if (hdr.dbh_pos_stored_sep)
	item_sz += 4;
    skip = hdr.index_hdr_sz 
	 + hdr.n_container * 8
	 + hdr.n_data_block_hdr * 8
	 + hdr.n_buckets * 8;

    srf_destroy(srf, 1);

    return (hdr.size - skip - 16/* footer*/) / item_sz;
}
예제 #5
0
파일: udb-inspect.c 프로젝트: LTD-Beget/nsd
/**
 * main program. Set options given commandline arguments.
 * @param argc: number of commandline arguments.
 * @param argv: array of commandline arguments.
 * @return: exit status of the program.
 */
int
main(int argc, char* argv[])
{
	int c, list=0;
	while( (c=getopt(argc, argv, "hlv")) != -1) {
		switch(c) {
		case 'l':
			list=1;
			break;
		case 'v':
			v++;
			break;
		default:
		case 'h':
			usage();
			return 1;
		}
	}
	argc -= optind;
	argv += optind;
	if(argc != 1) {
		usage();
		return 1;
	}
	if(list) list_file(argv[0]);
	else	inspect_file(argv[0]);

	return 0;
}
예제 #6
0
파일: tls.c 프로젝트: Distrotech/rsync
int
main(int argc, char *argv[])
{
	poptContext pc;
	const char **extra_args;
	int opt;

	pc = poptGetContext(PROGRAM, argc, (const char **)argv,
			    long_options, 0);
	while ((opt = poptGetNextOpt(pc)) != -1) {
		switch (opt) {
		case 'h':
			tls_usage(0);
		default:
			fprintf(stderr,
			        "%s: %s\n",
				poptBadOption(pc, POPT_BADOPTION_NOALIAS),
				poptStrerror(opt));
			tls_usage(1);
		}
	}

	extra_args = poptGetArgs(pc);
	if (!extra_args || *extra_args == NULL)
		tls_usage(1);

	for (; *extra_args; extra_args++)
		list_file(*extra_args);
	poptFreeContext(pc);

	return 0;
}
예제 #7
0
PRIVATE void list_print(char **buf, struct comal_line *line)
{
	struct print_rec *p = &line->lc.printrec;

	list_symsp(buf, line->cmd);

	if (p->modifier)
		switch (p->modifier->type) {
		case fileSYM:
			list_file(buf, &p->modifier->data.twoexp);
			break;

		case usingSYM:
			list_symsp(buf, usingSYM);
			list_exp(buf, p->modifier->data.str);
			list_text(buf, ": ");
			break;

		default:
			fatal("Print modifier incorrect");
		}

	list_printlist(buf, p->printroot);

	if (p->pr_sep)
		list_sym(buf, p->pr_sep);
}
예제 #8
0
void berth(int berth_number) {
    if (berths[berth_number].plane != NULL) {
        printf("Berth number %d cannot berth a plane at time %f because it is occupied.\n", berth_number+1, sim_time/60);
        exit(0);
    }

    if (taxi_state == TAXI_TRAVELLING_BERTHS)
        stats.taxi_time_travelling += (int)sim_time - stats.taxi_time_travelling_last;

    list_remove(FIRST, LIST_RUNWAY);
    struct plane *p = (struct plane *)malloc(sizeof(struct plane *));
    p->type = (int)transfer[EVENT_TYPE];
    p->id   = (int)transfer[PLANE_ID];
    //p->time_landed = (int)transfer[TIME_LANDED];
    berths[berth_number].plane = p;
    berths[berth_number].state = BERTH_TAKEN_LOADING;


    /* update time statistics for runway queue */
    //timest((float)sim_time - transfer[TIME_LANDED], TIMEST_RUNWAY);
    transfer[1] = sim_time;
    transfer[2] = list_size[LIST_RUNWAY];
    list_file(INCREASING, LIST_AVG_PLANES_RUNWAY);

    /* Schedule an event for the berth to finish loading */
    transfer[BERTH_NUMBER] = berth_number;
    transfer[PLANE_ID] = p->id;
    taxi_state = TAXI_BERTHING;
    stats.taxi_time_berthing_deberthing_last = (int)sim_time;
    event_schedule(sim_time+G.time_berth_deberth, EVENT_BERTH_FINISH);

    log_event(sim_time, EVENT_BERTH, taxi_state, p->id, storm_state, berth_number+1);
}
예제 #9
0
int main(int argc, char *argv[]) {
	char *startdir;
	char default_startdir[2] = ".";
	int leaf_depth;
	struct dirent **filelist;
	char tmp[1024];

	// argument가 3개일 때는 사용자가 target_dir과 depth를 설정할 수 있음.	
	if(argc == 3) {
		startdir = argv[1];
		leaf_depth = atoi(argv[2]);
	// argument가 2개일 때는 사용자가 target_dir만 설정 가능. depth는 default(= 0).
	} else if(argc == 2) {
		startdir = argv[1];
		leaf_depth = 0;
	// argument가 1개일 때는 target_dir : default("."), depth : default(= 0)
	} else if(argc == 1) {
		startdir = default_startdir;
		leaf_depth = 0;
	// 이외의 경우에는 사용법 출력
	} else {
		printf("[Usage] %s [target_dir] [depth]\n", argv[0]);
	}

	printf("%10s%10s%17s%17s%19s%14s\n", "d_ino", "d_type", "Access time", "Modify time", "Change time", "d_name");
	list_file(startdir, 0, leaf_depth);

	return 0;
}
void start_CPU_run(int jenis_job_queue)  /* Non-event function to start a CPU run of a job. */
{
    float run_time;

    /* Remove the first job from the queue. */

    list_remove(FIRST, jenis_job_queue);

    /* Determine the CPU time for this pass, including the swap time. */

    if (quantum < transfer[2])
        run_time = quantum + swap;
    else
        run_time = transfer[2] + swap;

    /* Decrement remaining CPU time by a full quantum.  (If less than a full
       quantum is needed, this attribute becomes negative.  This indicates that
       the job, after exiting the CPU for the current pass, will be done and is
       to be sent back to its terminal.) */

    transfer[2] -= quantum;

    /* Place the job into the CPU. */

    /* Schedule the end of the CPU run. */
    switch(jenis_job_queue){
        case LIST_QUEUE_1:
            list_file(FIRST, LIST_CPU_1);

	    event_schedule(sim_time + run_time, EVENT_END_CPU_1_RUN);
        break;
        case LIST_QUEUE_2:
            list_file(FIRST, LIST_CPU_2);

	    event_schedule(sim_time + run_time, EVENT_END_CPU_2_RUN);
        break;
        case LIST_QUEUE_3:
            list_file(FIRST, LIST_CPU_3);

	    event_schedule(sim_time + run_time, EVENT_END_CPU_3_RUN);
        break;
    }
}
예제 #11
0
파일: isal.c 프로젝트: gunnarrb/isal
void skaut_arrival() 
{
    push_array();
    int current_unit = (int)transfer[3];
    int i;
	
    for (i = NUM_MACHINES; i>=current_unit; i--) {  //add delay if there is a broken machine before current one

	if (machine_broken[i] > 0.0) {
	    if ((list_size[1+number_of_machines + current_unit] < queue_size[1+current_unit])||queue_size[1+current_unit] == 0) {  // if current machine is broken then delay it.x
		event_schedule(PREP_TIME+sim_time +  machine_broken[i] + work_time[current_unit], EVENT_SKAUT_ARRIVAL); //also if next queue is full then delay it.
		return;
	    }
	}
    }
	
    // check if machine is not busy
    if (list_size[current_unit] == 0 && machine_broken[current_unit] == 0.0) {
	sampst(0.0, sampst_delays);
	sampst(0.0, current_unit);
	    
	list_file(FIRST, current_unit); // last := first here because there are only to be 0 or 1 items in machine
		
	// schedule departure after machine processing time
	pop_array();
	event_schedule(PREP_TIME + sim_time + work_time[current_unit], EVENT_SKAUT_DEPARTURE);
    } else {
		
	if (list_size[number_of_machines + current_unit] == queue_size[current_unit]) {
			
	    event_schedule(PREP_TIME + sim_time + work_time[current_unit], EVENT_SKAUT_ARRIVAL); //also if queue is full then delay it.
			
	} else {
	    transfer[5] = sim_time;
	    list_file(LAST, number_of_machines + current_unit);
	    if(list_size[current_unit] > queue_max_lengths[number_of_machines + current_unit]) {
		queue_max_lengths[current_unit] = list_size[number_of_machines + current_unit];
	    }
	}
		
    }
	
}
예제 #12
0
/*
 * Lists the contents of a .hash file
 */
int main(int argc, char **argv) {
    opts opts;
    int i, c;
    int64_t count = 0;

    opts.long_format = 0;
    opts.count_only = 0;
    opts.verbose = 0;

    while ((c = getopt(argc, argv, "lcvh")) != -1) {
	switch (c) {
	case 'l':
	    opts.long_format = 1;
	    break;

	case 'c':
	    opts.count_only = 1;
	    break;

	case 'v':
	    opts.verbose = 1;
	    break;

	case 'h':
	    usage(0);

	default:
	    usage(1);
	}
    }

    for (i = optind; i < argc; i++) {
	int64_t c;

	if (opts.count_only)
	    c = count_file(argv[i], &opts);
	else
	    c = list_file(argv[i], &opts);

	if (c < 0)
	    return 1;

	if (opts.verbose)
	    printf("%s: %"PRId64" sequences\n", argv[i], c);
	count += c;
    }
    
    if (opts.count_only)
	printf("%"PRId64"\n", count);

    return 0;
}
예제 #13
0
void plane_land(int plane_type, int plane_id) {
    /* Add the plane in transfer to the runway queue */
    transfer[PLANE_ID] = plane_id;
    transfer[TIME_LANDED] = sim_time/60;
    transfer[EVENT_TYPE] = plane_type;
    list_file(LAST, LIST_RUNWAY);

    /* Add the event to the log list */
    log_event(sim_time, plane_type, taxi_state, plane_id, storm_state, 0);

    /* update time statistics for runway queue */
    timest((float)sim_time - transfer[TIME_LANDED], TIMEST_RUNWAY);
    transfer[1] = sim_time;
    transfer[2] = list_size[LIST_RUNWAY];
    list_file(INCREASING, LIST_AVG_PLANES_RUNWAY);

    /* Add plane to in-port residence time list */
    transfer[PLANE_ID] = plane_id;
    transfer[TIME_LANDED] = sim_time;
    transfer[PLANE_TYPE] = plane_type;
    list_file(INCREASING, LIST_PLANE_PORT_TIME);
}
예제 #14
0
파일: simlib.c 프로젝트: gunnarrb/isal
void
event_schedule (double time_of_event, int type_of_event)
{

/* Schedule an event at time event_time of type event_type.  If attributes
   beyond the first two (reserved for the event time and the event type) are
   being used in the event list, it is the user's responsibility to place their
   values into the transfer array before invoking event_schedule. */

  transfer[EVENT_TIME] = time_of_event;
  transfer[EVENT_TYPE] = type_of_event;
  list_file (INCREASING, LIST_EVENT);
}
예제 #15
0
int init_gui()
{	WIN win;
	int ch;
        int i;
        char ** files;

	initscr();			/* Start curses mode 		*/
	start_color();			/* Start the color functionality */
	cbreak();			/* Line buffering disabled, Pass on
					 * everty thing to me 		*/
	keypad(stdscr, TRUE);		/* I need that nifty F1 	*/
	noecho();
	init_pair(1, COLOR_CYAN, COLOR_BLACK);
        init_pair(2, COLOR_GREEN, COLOR_BLACK);

	/* Initialize the window parameters */
	init_win_params(&win);
	print_win_params(&win);

	attron(COLOR_PAIR(1));
        printw("F2: Ouvrir un fichier");
        printw("\t F3: Lancer l'émulation");
	printw("\t F5: Quitter");
        attron(A_BOLD);
        attron(COLOR_PAIR(2));
        char chaine[]="Welcome to ProcSI emulator";
        mvprintw((LINES/2) -3,(COLS-strlen(chaine))/2,chaine);
        attroff(A_BOLD);
	refresh();
	attroff(COLOR_PAIR(1));
	
	create_box(&win, TRUE);
        draw_menu(choices, execute_main_menu, "", 3);
        
	while((ch = getch()) != KEY_F(5))
	{
            switch(ch)
	    {	case KEY_F(5):
                        mvprintw(LINES-2, 0, "Exiting...");
                        endwin();			/* End curses mode		  */
                        exit(0);
            
                case KEY_F(2):
                        files = list_file("", &i);
                        draw_menu(files, execute_file_menu, "", i);
            }
            
	}
	endwin();			/* End curses mode		  */
	return 0;
}
예제 #16
0
파일: myls.c 프로젝트: hyewon20/MyShell
int main (int argc, char **argv)
{
    if(argc >= 2) {
        if(strcmp(argv[1], "--help") == 0) {
            print_help();
        } else {
            struct stat st;
            if (stat(argv[1], &st) == 0) {
                if (S_ISDIR(st.st_mode)) {
                    list_file(argv[1], "");
                } else {
                    /* myls [FILENAME] */
                    list_file(".", argv[1]);
                }
            } else {
                fprintf(stderr, "%s: No such file or directory.\n", argv[1]);
            }
        }
    } else {
        list_file(".", "");
    }
    return 0;
}
예제 #17
0
파일: tls.c 프로젝트: locked/rsync-pgsql
int
main(int argc, char *argv[])
{
	if (argc < 2) {
		fprintf(stderr, "usage: " PROGRAM " FILE ...\n"
			"Trivial file listing program for portably checking rsync\n");
		return 1;
	}

	for (argv++; *argv; argv++) {
		list_file(*argv);
	}

	return 0;
}
예제 #18
0
// ls     => ls <cwd>
// ls dir => ls <cwd>/dir
// ls a/b/c 
// ls a/b/c e/f/g /h/i/j
int my_ls(int argc, char* argv[])
{
    result_t result = NONE;
    const int device = running->cwd->device;

    // If given no path, ls cwd
    if(argc < 2)
    {
        list_dir(running->cwd);
        return SUCCESS;
    }

    // ls each path given by user
    int i = 1;
    while(i < argc)
    {
        int ino = getino(device, argv[i]);
        MINODE* mip = iget(device, ino);

        if(!mip)
        {
            result = DOES_NOT_EXIST;
            printf("ls: cannot access '%s':"
                    " No such file or directory\n", argv[i]);
            goto clean_up;
        }

        // If printing multiple lists label each one
        if(argc > 2)
            printf("%s:\n", argv[i]);

        if(S_ISDIR(mip->inode.i_mode))
            list_dir(mip);
        else
            list_file(mip, argv[i]);

clean_up:
        // Move parent inode from memory to disk
        iput(mip);

        if(result != NONE)
            return result;

        i++;
    }

    return SUCCESS;
}
예제 #19
0
void *cook_mission(void * arg){
    int lastMaxTime = 0;
    while(cookLive == YES){
        //Print_Queue_Item(queue);
        int newMaxTime = list_file((char*)arg, lastMaxTime);
        if(newMaxTime == lastMaxTime){
            printf("[Receiver] till now repeated pack num = %d\n", repeated);
            printf("[Cook] no new file , will check again in 2 sec...\n");
            sleep(2);
        }else{
            lastMaxTime = newMaxTime;
            printf("[Cook] Cook list Done, lastMaxTime changed to %d\n", newMaxTime);
        }
    }
    return NULL;
}
예제 #20
0
MyMainWindow::MyMainWindow(QWidget *parent) :
	QMainWindow(parent), ui(new Ui::MyMainWindow), file_model(nullptr)//new MyFileSystemModel(this))
{
	ui->setupUi(this);

	setWindowTitle("QtCrypt");

	/*
	ui->tree_view->setModel(file_model);
	ui->tree_view->hideColumn(MyFileSystemModelPublic::FULL_PATH_HEADER);
	ui->tree_view->hideColumn(MyFileSystemModelPublic::TYPE_HEADER);

	for(int i = 0; i < MyFileSystemModelPublic::COLUMN_NUM; i++)
		ui->tree_view->resizeColumnToContents(i);
	*/

	setModel(new MyFileSystemModel(nullptr));

	ui->password_0->setEchoMode(QLineEdit::Password);
	ui->password_1->setEchoMode(QLineEdit::Password);

	// note that some password information will be discarded if the text characters entered use more
	// than	1 byte per character in UTF-8
	ui->password_0->setMaxLength(crypto_secretbox_KEYBYTES);
	ui->password_1->setMaxLength(crypto_secretbox_KEYBYTES);

	// initialize the zipping text codec, specifically, for use in encryption and decryption
	QuaZip::setDefaultFileNameCodec("UTF-8");

	ui->encrypt_filename->setMaxLength(MAX_ENCRYPT_NAME_LENGTH);
	ui->auto_resize->setChecked(true);

	// create the temp directory and session.qtlist if they don't exist already
	QDir curr_dir = QDir::current();
	QFile list_file(DEFAULT_LIST_PATH);

	if(!curr_dir.exists(QString("temp")))
		curr_dir.mkdir(QString("temp"));

	if(!list_file.exists())
	{
		list_file.open(QIODevice::WriteOnly);
		list_file.close();
	}
}
예제 #21
0
void execute_main_menu(int choice,const char * choice_name, char * folder){
    //mvprintw(9, 0, "Item selected is : %i", choice);
    
    //un case serais plus approprier ... à modifier si j'ai le temps
    if(choice == 0){
        int i;
        char ** files = list_file("", &i);
        draw_menu(files, execute_file_menu, "", i);
        
    }
    
    if(choice == 2){
        mvprintw(LINES-2, 0, "Exiting...");
        endwin();			/* End curses mode		  */
        exit(0);
    }
    
}
예제 #22
0
파일: isal.c 프로젝트: gunnarrb/isal
void skaut_departure()
{
    push_array();
    int current_unit = (int) transfer[3];
    int i = 0;
    for (i = NUM_MACHINES; i>=current_unit; i--) {  //add delay if machine is broken or there is a broken machine before current one

	if (machine_broken[i] > 0.0) {
	    if ((i == current_unit)  || (list_size[1+number_of_machines + current_unit] < queue_size[1+current_unit])) {  // if current machine is broken then delay it.
		event_schedule(PREP_TIME+sim_time + machine_broken[i], EVENT_SKAUT_DEPARTURE); //also if next queue is full then delay it.
		return;
	    }
//	    printf("Size of next queue %d, limit of next queue %d\n",list_size[1+number_of_machines + current_unit], queue_size[1+current_unit]);
	    break;
	}
    }
	
    if (current_unit == MACHINES_ON_THE_LEFT_SIDE) {
	skaut_throughput += 2;
	sampst(sim_time - transfer[4], throughput_time);
	list_remove(FIRST,current_unit);  
    } else {
	list_remove(FIRST,current_unit);
	pop_array();
	transfer[3]++;
	event_schedule(PREP_TIME + sim_time + transfer_time[(int)(transfer[3])-1], EVENT_SKAUT_ARRIVAL);
    }
	
	
    if (list_size[number_of_machines + current_unit] != 0) {
	pop_array();
		
	list_file(FIRST,current_unit); // first equals last because size should only be 1
	pop_array();
		
	list_remove(FIRST, number_of_machines + current_unit);
	pop_array();
		
	sampst(sim_time - transfer[5], sampst_delays);
	sampst(sim_time - transfer[5], current_unit);
	event_schedule(PREP_TIME + sim_time + work_time[current_unit], EVENT_SKAUT_DEPARTURE);
    }
}
예제 #23
0
void finish_loading(int berth_number) {
    berths[berth_number].state = BERTH_TAKEN_NOT_LOADING;
    berths[berth_number].time_finish_loading = sim_time;

    /*  Add up the time the berth was loading
        The berth becomes occupied but not loading at this point.  */
    berths[berth_number].time_loading += (int)sim_time - berths[berth_number].time_loading_last;
    berths[berth_number].time_occupied_last = sim_time;

    struct plane *p = berths[berth_number].plane;

    transfer[EVENT_TIME] = sim_time;
    transfer[2] = check_num_berths_finished();
    list_file(INCREASING, LIST_AVG_PLANES_DEBERTH);

    log_event(sim_time, EVENT_FINISH_LOADING, taxi_state, p->id, storm_state, berth_number+1);

    //if (taxi_state == TAXI_IDLE)
      //  taxi_idle();
}
예제 #24
0
void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path)
{
    QFile list_file(path);
    if (!list_file.open(QFile::ReadOnly)) {
        QMessageBox::warning(this, tr("I/O Error"), tr("Error while trying to open the downloaded file."), QMessageBox::Ok);
        setCursor(Qt::ArrowCursor);
        uTorrentListButton->setEnabled(true);
        Utils::Fs::forceRemove(path);
        return;
    }

    // Load from torrent handle
    QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
    // Load from current user list
    QStringList tmp = trackers_list->toPlainText().split("\n");
    foreach (const QString &user_url, tmp) {
        BitTorrent::TrackerEntry userTracker(user_url);
        if (!existingTrackers.contains(userTracker))
            existingTrackers << userTracker;
    }
예제 #25
0
void deberth(int berth_number) {
    if (berths[berth_number].plane == NULL) {
        printf("Berth number %d cannot deberth a plane at time %d because it is not occupied.\n", berth_number+1, sim_time);
        exit(0);
    }

    if (berths[berth_number].state == BERTH_TAKEN_LOADING) {
        printf("Berth number %d cannot deberth a plane at time %d because it is not finished unloading.\n", berth_number, sim_time);
        exit(0);
    }

    berths[berth_number].state = BERTH_FREE;
    /*  Add times to deberthing queue list to get stats  */
    transfer[1] = sim_time;
    transfer[2] = check_num_berths_finished();
    list_file(INCREASING, LIST_AVG_PLANES_DEBERTH);

    /* Remove the plane from the berth */
    struct plane *p = berths[berth_number].plane;
    berths[berth_number].time_finish_loading = NULL;

    transfer[BERTH_NUMBER] = berth_number;
    transfer[PLANE_ID] = p->id;
    taxi_state = TAXI_DEBERTHING;
    berths[berth_number].state = BERTH_FREE;

    /*  Add up the time the berth was occupied but not loading
        The berth frees up at this point.  */
    berths[berth_number].time_occupied += (int)sim_time - berths[berth_number].time_occupied_last;
    berths[berth_number].time_unoccupied_last = sim_time;

    /* Set the time that the taxi starts berthing/deberthing */
    stats.taxi_time_berthing_deberthing_last = (int)sim_time;

    event_schedule(sim_time+G.time_berth_deberth, EVENT_DEBERTH_FINISH);

    log_event(sim_time, EVENT_DEBERTH, taxi_state, p->id, storm_state, berth_number+1);
    //berths[berth_number].plane = NULL;


}
예제 #26
0
void list_file(char *startdir, int depth, int leaf_depth) {
	struct dirent **filelist;
	struct stat stat1;
	int count, i;
	char *dir;
	int num_blanks = depth*2;
	char current_dir[1024];

	// leaf_depth에 도달하면 함수 종료
	if(depth > leaf_depth) {
		return;
	}
	
	// current directory 변경(상대경로 절대경로 문제가 생길 수 있기 때문)
	chdir(startdir);
	getcwd(current_dir, 1024);

	// start directory의 filelist 저장
	count = scandir(current_dir, &filelist, NULL, alphasort);
	
	// scandir 결과(filelist)를 출력하고 directory일 경우 재귀로 list_file호출
	for(i=0; i<count; i++) {
		// file의 정보 얻기(mac time을 얻기 위해)
		lstat(filelist[i]->d_name, &stat1);

		// directory일 경우 파일명의 마지막에 "/" 붙임
		if(filelist[i]->d_type == 4) {
			printf("%10d, %8s, %s, %s, %s,   %*s%s/\n", filelist[i]->d_ino, get_filetype(filelist[i]->d_type), time_to_char(stat1.st_atime), time_to_char(stat1.st_mtime), time_to_char(stat1.st_ctime), num_blanks, "", filelist[i]->d_name);
		} else {
			printf("%10d, %8s, %s, %s, %s,   %*s%s\n", filelist[i]->d_ino, get_filetype(filelist[i]->d_type), time_to_char(stat1.st_atime), time_to_char(stat1.st_mtime), time_to_char(stat1.st_ctime), num_blanks, "", filelist[i]->d_name);
		}

		// "."과 ".." directory는 재귀 호출에서 제외
		if((filelist[i]->d_type == 4) && strcmp(filelist[i]->d_name, ".") && strcmp(filelist[i]->d_name, "..")) {
			dir = filelist[i]->d_name;
			list_file(dir, depth+1, leaf_depth);
		}
	}

	chdir("..");
}
예제 #27
0
파일: mdir.c 프로젝트: Distrotech/mtools
static int list_non_recurs_directory(direntry_t *entry, MainParam_t *mp)
{
	int r;
	/* list top-level directory
	 *   If this was matched by wildcard in the basename, list it as
	 *   file, otherwise, list it as directory */
	if (mp->basenameHasWildcard) {
		/* wildcard, list it as file */
		return list_file(entry, mp);
	} else {
		/* no wildcard, list it as directory */
		MainParam_t subMp;

		r=enterDirectory(mp->File);
		if(r)
			return ERROR_ONE;

		subMp = *mp;
		subMp.dirCallback = subMp.callback;
		return mp->loop(mp->File, &subMp, "*") | GOT_ONE;
	}
}
void arrive(void)  /* Event function for arrival of job at CPU after think
                      time. */
{

    /* Place the arriving job at the end of the CPU queue.
       Note that the following attributes are stored for each job record:
            1. Time of arrival to the computer.
            2. The (remaining) CPU service time required (here equal to the
               total service time since the job is just arriving).*/

    transfer[1] = sim_time;
    transfer[2] = expon(mean_service, STREAM_SERVICE);//TODO nanti ganti sama distribusi yang disebut di spek (belum jelas)
    //jenis job
    int jenis_job;
    if (transfer[2]<=batasatasjob1)
        jenis_job=LIST_QUEUE_1;
    else if (transfer[2]<=batasatasjob2)
        jenis_job=LIST_QUEUE_2;
    else
        jenis_job=LIST_QUEUE_3;
    list_file(LAST, jenis_job); 

    /* If the CPU is idle, start a CPU run. */
    switch(jenis_job){
        case LIST_QUEUE_1:
        if (list_size[LIST_CPU_1] == 0)
            start_CPU_run(jenis_job);
        break;
        case LIST_QUEUE_2:
        if (list_size[LIST_CPU_2] == 0)
            start_CPU_run(jenis_job);
        break;
        case LIST_QUEUE_3:
        if (list_size[LIST_CPU_3] == 0)
            start_CPU_run(jenis_job);
        break;
    }
}
예제 #29
0
PRIVATE void list_input(char **buf, struct comal_line *line)
{
	struct input_rec *i = &line->lc.inputrec;

	list_symsp(buf, line->cmd);

	if (i->modifier)
		switch (i->modifier->type) {
		case fileSYM:
			list_file(buf, &i->modifier->data.twoexp);
			break;

		case stringSYM:
			list_string(buf, i->modifier->data.str->s);
			list_text(buf, ": ");
			break;

		default:
			fatal("Input modifier incorrect");
		}

	list_explist(buf, i->lvalroot, 0);
}
예제 #30
0
// Displays each directory entry
// Assumes the given minode exists and is a directory
void list_dir(MINODE* mip)
{
    const int device = mip->device;
    const int block_size = get_block_size(device);

    INODE* ip = &mip->inode;

    // For DIR inodes, assume that (the number of entries is small so that) only has
    // 12 DIRECT data blocks. Therefore, search only the direct blocks.
    for(int i = 0; i < (ip->i_size / block_size); i++)
    {
        if (ip->i_block[i] == EMPTY || i >= NUM_DIRECT_BLOCKS)
            break;

        u8* block = get_block(device, ip->i_block[i]);
        u8* cp = block; 
        DIR* dp = (DIR*)block;

        // While within the block
        while (cp < block + block_size)
        {
            char name[MAX_FILE_NAME_LENGTH];
            strncpy(name, dp->name, dp->name_len);
            name[dp->name_len] = '\0';

            MINODE* cip = iget(device, dp->inode);
            list_file(cip, name);
            putchar('\n');
            iput(cip);

            cp += dp->rec_len; // advance cp by rec_len bytes 
            dp = (DIR*)cp;     // pull dp along to the next record
        } 

        free(block);
    }
}