Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1.  
  2. #ifndef __KOS_IO_H__
  3. #define __KOS_IO_H__
  4.  
  5. #pragma pack(push, 1)
  6. typedef struct
  7. {
  8.   char sec;
  9.   char min;
  10.   char hour;
  11.   char rsv;
  12. }detime_t;
  13.  
  14. typedef struct
  15. {
  16.   char  day;
  17.   char  month;
  18.   short year;
  19. }dedate_t;
  20.  
  21. typedef struct
  22. {
  23.   unsigned    attr;
  24.   unsigned    flags;
  25.   union
  26.   {
  27.      detime_t  ctime;
  28.      unsigned  cr_time;
  29.   };
  30.   union
  31.   {
  32.      dedate_t  cdate;
  33.      unsigned  cr_date;
  34.   };
  35.   union
  36.   {
  37.      detime_t  atime;
  38.      unsigned  acc_time;
  39.   };
  40.   union
  41.   {
  42.      dedate_t  adate;
  43.      unsigned  acc_date;
  44.   };
  45.   union
  46.   {
  47.      detime_t  mtime;
  48.      unsigned  mod_time;
  49.   };
  50.   union
  51.   {
  52.      dedate_t  mdate;
  53.      unsigned  mod_date;
  54.   };
  55.   unsigned    size;
  56.   unsigned    size_high;
  57. } fileinfo_t;
  58.  
  59. #pragma pack(pop)
  60.  
  61. int create_file(const char *path);
  62. int get_fileinfo(const char *path, fileinfo_t *info);
  63. int read_file(const char *path, void *buff,
  64.                size_t offset, size_t count, size_t *reads);
  65. int write_file(const char *path,const void *buff,
  66.                size_t offset, size_t count, size_t *writes);
  67. int set_file_size(const char *path, unsigned size);
  68. void *load_file(const char *path, size_t *len);
  69. void __stdcall unpack(void* packed_data, void* unpacked_data);
  70.  
  71. static inline int user_free(void *mem)
  72. {
  73.     int  val;
  74.     __asm__ __volatile__(
  75.     "int $0x40"
  76.     :"=a"(val)
  77.     :"a"(68),"b"(12),"c"(mem));
  78.     return val;
  79. }
  80.  
  81. static inline void set_cwd(const char* cwd)
  82. {
  83.     __asm__ __volatile__(
  84.     "int $0x40"
  85.     ::"a"(30),"b"(1),"c"(cwd));
  86. };
  87.  
  88. #endif
  89.