コード例 #1
0
ファイル: fsinfo.c プロジェクト: wideglide/CS2140
void read_from_file(FILE* fd) {
	char buf[FILENAME_MAX], c;		/* buf is our input buffer */
	int i;
	
	/* read in each line from file, fgets returns NULL when done */
	while (fgets(buf, FILENAME_MAX, fd)) { 
		i = 0;
		c = buf[i];
		while(c != '\0') {	/* check for terminating character */
			/* check for # or terminating char, 
			 * fill remaining buffer with 0's */
			if (c== '#' || isspace(c)) bzero(&buf[i], FILENAME_MAX-i);
			i++;			/* count suspected good input */
			c = buf[i];
		}
		if (buf[0] == '\0') continue;	/* no good input found */
		if (verbose) fprintf(stderr, "file arg: %s\n",buf);
		/* call show_stat, show_dir and show_fs from here as required,
		 * this will save having to pass muliple buffers back to main,
		 * terminate when done. */
		show_stat(buf);
		show_dir(buf);
		if (filesystem) show_fs(buf);
		bzero(&buf, FILENAME_MAX);	/* reset our buffer to all zero's */
	}
	fclose(fd);
	exit(EXIT_SUCCESS);
}
コード例 #2
0
ファイル: main.c プロジェクト: codeliuer/learn-code
int
main(int argc, char * argv[])
{
    if (argc != 2)
    {
        fprintf(stderr, "Usage: ./a.out directory\n");
        return EXIT_FAILURE;
    }

    show_dir(argv[1]);

    return EXIT_SUCCESS;
}
コード例 #3
0
ファイル: moc_popup.cpp プロジェクト: x27lu/TLPlaylistCreator
int Popup4::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: get_index_then_close(); break;
        case 1: show_dir(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
コード例 #4
0
ファイル: fsinfo.c プロジェクト: wideglide/CS2140
int main(int argc, char *argv[])
{
    if (argc < 2) usage(argv[0]);
    int opt, i, j;
    FILE *file_in, *file_out;		/* declare file pointers for use */
    file_in = file_out = NULL;

    while( -1 != (opt = getopt_long(argc, argv, "hvi:o:f", long_opts, &i)) ) {
        switch(opt) {
            case 'h':
                usage(argv[0]);
                break;
            case 'v':
                verbose = 1;
                printf(" --verbose enabled-- \n");
		fflush(stdout);
                break;
            case 'f':
				filesystem = 1;
                break;
            case 'i':
				file_in = fopen(optarg, "r");
				break;
            case 'o':
				file_out = freopen(optarg, "w", stdout);
				break;
            default:
                fprintf(stderr, "Invalid option.\n");
                usage(argv[0]);
                break;
        }
    } // while
    if (file_in) read_from_file(file_in);	/* if input file was specified */
    
    for (j = optind; j < argc; j++) {	/* iterate through argv starting */
		show_stat(argv[j]);		/*  with optind position */
		show_dir(argv[j]);
		if (filesystem) show_fs(argv[j]);	/* check for -f flag */
	}
	
	if (file_in) fclose(file_in);
	if (file_out) fclose(file_out);	/* be sure to close file ptrs */
	return 0;
}
コード例 #5
0
ファイル: tty.c プロジェクト: fuxingwe/papaya
static void ls(char*path){
	loadfile(path,loadbuf);
	show_dir(loadbuf);
//	oprintf("%s\n",loadbuf);
}
コード例 #6
0
ファイル: main.c プロジェクト: vbmacher/qsOS
int main()
{
  int key;
  int sel, old_sel;

  printf("\nLoading...");

  Init_PHY();
  Init_LOG();
  Init_APP();

  sel = 0;
  old_sel = 0;
start:
  mainmenu(sel);

  // kbhit
  fflush(stdin);
  key = 0;
  asm {
    mov ax, 0x0305
    xor bx, bx
    int 0x16
  }
key_loop:
  while (!kbhit()) ;
  asm {
    xor ah, ah
    int 0x16
    mov byte ptr [key], ah // scan kod
  }

  switch (key) {
    case 0x50: // dole
      old_sel = sel;
      sel++;
      if (sel == menu_count) sel = 0;
      sel_item(sel,old_sel);
      goto key_loop;
    case 0x48: // hore
      old_sel = sel;
      if (!sel) sel = menu_count;
      sel--;
      sel_item(sel, old_sel);
      goto key_loop;
    case 0xE0:
    case 0x1C: // enter
      break;
    default:
      goto key_loop;
  }

  draw_window();
  switch (sel) {
    case CREATE_FILE:
      create_file(NULL);
      break;
    case DELETE_FILE:
      delete_file(NULL);
      break;
    case WRITE_FILE:
      write_file(NULL,NULL,0,0,1);
      cprintf("\n\rPress ENTER");
      cgets(NULL);
      break;
    case READ_FILE:
      read_file(NULL,NULL,0,0,1);
      cprintf("\n\rPress ENTER");
      cgets(NULL);
      break;
    case CREATE_DIR:
      create_dir(NULL);
      break;
    case DELETE_DIR:
      delete_dir(NULL);
      break;
    case SHOW_DIR:
      show_dir();
      break;
    case SET_PATH:
      set_path(NULL);
      break;
    case DISK_INFO:
      disk_info();
      break;
    case FORMAT_FDD:
      format_fdd();
      break;
    case FDD_TEST:
      dotest_fdd();
      break;
    case ABOUT:
      about();
      break;
    case EXIT:
      goto ext;
  }

  textattr(BORDER);
  cprintf("\n\r\n\rPress any key to continue...");
  getchar();
  goto start;

ext:
  window(1,1,80,25);
  textattr(0x07);
  clrscr();

  Destroy_APP();
  Destroy_LOG();
  Destroy_PHY();

  return 0;
}