Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  3. #include <libc/stubs.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <dirent.h>
  7. #include <errno.h>
  8. #include <limits.h>
  9. #include <unistd.h>
  10. #include <sys/stat.h>
  11. #include "dirstruc.h"
  12.  
  13. DIR *
  14. opendir(const char *name)
  15. {
  16.         int res;
  17.         DIR* dir = (DIR*)malloc(sizeof(DIR));
  18.         if (!dir)
  19.                 return NULL;
  20.         _fixpath(name, dir->fileinfo.name);
  21.         struct bdfe_item attr;
  22.         dir->fileinfo.command = 5;
  23.         dir->fileinfo.file_offset_low = 0;
  24.         dir->fileinfo.file_offset_high = 0;
  25.         dir->fileinfo.size = 0;
  26.         dir->fileinfo.data_pointer = (__u32)&attr;
  27.         res = __kolibri__system_tree_access2(&dir->fileinfo);
  28.         if (res!=0 && res!=2)
  29.         {
  30.                 free(dir);
  31.                 return NULL;
  32.         }
  33.         if (res==0 && (attr.attr & 0x10)==0)
  34.         {
  35.                 free(dir);
  36.                 return NULL;
  37.         }
  38.         dir->fileinfo.command = 1;
  39.         dir->fileinfo.size = 1;
  40.         dir->fileinfo.data_pointer = (__u32)dir->bdfeheader;
  41.         dir->fileinfo.file_offset_low = (__u32)-1;
  42.         return dir;
  43. }
  44.