コード例 #1
0
ファイル: files.c プロジェクト: doomglue/aleph
void list_scan(dirList_t* list, const char* path) {
  FL_DIR dirstat; 
  struct fs_dir_ent dirent;

  list->num = 0;
  strcpy(list->path, path);

  if( fl_opendir(path, &dirstat) ) {      
    while (fl_readdir(&dirstat, &dirent) == 0) {
      if( !(dirent.is_dir) ) {
	strcpy((char*)(list->nameBuf + (list->num * DIR_LIST_NAME_LEN)), dirent.filename);
	print_dbg("\r\n added file: ");
	print_dbg(dirent.filename);
	print_dbg(" , count: ");
	print_dbg_ulong(list->num);
	list->num += 1;
      }
    }
  }
  print_dbg("\r\n scanned list at path: ");
  print_dbg(list->path);
  print_dbg(" , contents : \r\n");
  print_dbg((const char*)list->nameBuf);
  print_dbg("\r\n");
}
コード例 #2
0
ファイル: files.c プロジェクト: Someone101/aleph
void list_scan(dirList_t* list, const char* path) {
  FL_DIR dirstat; 
  struct fs_dir_ent dirent;
  int i;

  // clear out the buffers...
  for(i=0; i<DIR_LIST_NAME_BUF_SIZE; ++i) {
    list->nameBuf[i] = '\0';
  }

  list->num = 0;
  strcpy(list->path, path);

  if( fl_opendir(path, &dirstat) ) {      
    while (fl_readdir(&dirstat, &dirent) == 0) {
      if( !(dirent.is_dir) ) {
	strncpy((char*)(list->nameBuf + (list->num * DIR_LIST_NAME_LEN)), dirent.filename, DIR_LIST_NAME_LEN_1);
	*(list->nameBuf + (list->num * DIR_LIST_NAME_LEN) + DIR_LIST_NAME_LEN_1) = '\0';
	print_dbg("\r\n added file: ");
	print_dbg(dirent.filename);
	print_dbg(" , count: ");
	print_dbg_ulong(list->num);
	list->num += 1;
      }
    }
  }
  print_dbg("\r\n scanned list at path: ");
  print_dbg(list->path);
  print_dbg(" , contents : \r\n");

  /* for(i=0; i<list->num; i++) { */
  /*   char buf[32]; */
  /*   u8 j; */
  /*   strncpy( buf, list_get_name(list, i), 32 ); */

  /*   print_dbg(buf); */

  /*   for(j=0; j<32; j++) { */
  /*     print_dbg( " 0x"); */
  /*     print_dbg_hex(buf[j]); */
  /*     print_dbg( " " ); */
  /*     if(!(j%8)) { print_dbg("\r\n"); } */
  /*   } */
  /*   print_dbg("\r\n"); */
  /* } */
  /* print_dbg("\r\n"); */
}
コード例 #3
0
ファイル: ls.c プロジェクト: everslick/piratos
void
list_directory(CLI *cli, const char *path) {
    FL_DIR dirstat;

    if (fl_opendir(path, &dirstat)) {
        struct fs_dir_ent dirent;

        while (fl_readdir(&dirstat, &dirent) == 0) {
            if (dirent.is_dir) {
                printf("%s \t<DIR>\n", dirent.filename);
            } else {
                printf("%s \t[%d bytes]\n", dirent.filename, (int)dirent.size);
            }
        }

        fl_closedir(&dirstat);
    }
}
コード例 #4
0
ファイル: files.c プロジェクト: Someone101/aleph
// search for a given filename in a listed directory. set size by pointer
void* list_open_file_name(dirList_t* list, const char* name, const char* mode, u32* size) {
  FL_DIR dirstat;
  struct fs_dir_ent dirent;
  char path[64];
  void* fp;

  print_dbg("\r\n *list_open_file_name: "); 
  print_dbg(path); 
  print_dbg(" at ");
  print_dbg(list->path);
  print_dbg(" request: ");
  print_dbg(name);


  strcpy(path, list->path);

  if(fl_opendir(path, &dirstat)) {
    
    while (fl_readdir(&dirstat, &dirent) == 0) {
      print_dbg("\r\n ... checking against "); 
      print_dbg(dirent.filename);

      if (strcmp(dirent.filename, name) == 0) {
	strncat(path, dirent.filename, 58);
	
	print_dbg("\r\n ... found, opening at:  "); 
	print_dbg(path);
      
	fp = fl_fopen(path, mode);
	*size = dirent.size;
	break;
      } else { // no match on this entry
	*size = 0;
	fp = NULL;
      }
    } // end loop
  } else { // dir error
    print_dbg("\r\n directory error.");
    *size = 0;
    fp = NULL;
  }
  return fp;
}
コード例 #5
0
ファイル: file.c プロジェクト: TeamOberland/OberlaenderOS
int32_t file_readdir(dir_handle_t dirls, api_file_direntry_t* entry)
{
    return fl_readdir((FL_DIR*) dirls, (fl_dirent*) entry);
}