#include "pj1.h"
#include <stdio.h>

char *type_to_str(unsigned char t){
  if(t == FILE_DIR) return "dir";
  if(t == FILE_NORMAL) return "file";
  if(t == FILE_OTHER) return "other";
  return "??";
}//

int main(int argc, char *argv[]){
  char *fileName;
  char path[1024];
  int   ret;
  SDirEntry entry;
  
  ret = open_directory(argv[1]);
  os_assert(ret == 0);
  printf("%-20s%-8s%-12s%-12s\n",
	 "file name", "type", "modify time", "size");
  printf("\n");
  while(fileName = read_an_entry()){
    strcpy(path, argv[1]);
    strcat(path, "/");
    strcat(path, fileName);
    ret = get_file_info(path, &entry);
    os_assert(ret == 0);
    printf("%-20s%-8s%-12d%-12d\n", entry.fileName,
	   type_to_str(entry.fileType),
	   entry.lastModifyTime,
	   entry.fileSize);
  }//while
  close_directory();
}//main
