Subversion Repositories Kolibri OS

Rev

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

  1. #include <stdlib.h>
  2. #include <dir.h>
  3. #include <stdbool.h>
  4.  
  5. #pragma pack(push,1)
  6. typedef struct {
  7.     unsigned    p00;
  8.     unsigned long long  p04;
  9.     unsigned    p12;
  10.     unsigned    p16;
  11.     char                p20;
  12.     char                *p21;
  13. } kol_struct70;
  14. #pragma pack(pop)
  15.  
  16. int kol_file_70(kol_struct70 *k)
  17. {
  18.     asm volatile ("int $0x40"::"a"(70), "b"(k));
  19. }
  20.  
  21. bool dir_operations(unsigned char fun_num, char *path)
  22. {
  23.     kol_struct70 inf;
  24.     inf.p00 = fun_num;
  25.     inf.p04 = 0;
  26.     inf.p12 = 0;
  27.     inf.p16 = 0;
  28.     inf.p20 = 0;
  29.     inf.p21 = path;
  30.     if(!kol_file_70(&inf)){
  31.         return true;
  32.     }
  33.     else {
  34.             return false;
  35.     }
  36. }
  37.  
  38. char *getcwd(char *buf, unsigned size)
  39. {
  40.     if(buf == NULL){
  41.         buf = malloc(size);
  42.     }
  43.     __asm__ __volatile__(
  44.     "int $0x40"
  45.     ::"a"(30),"b"(2),"c"(buf), "d"(size));
  46.     return(buf);
  47. }
  48.  
  49. void setcwd(const char* cwd)
  50. {
  51.     __asm__ __volatile__(
  52.     "int $0x40"
  53.     ::"a"(30),"b"(1),"c"(cwd));
  54. }
  55.  
  56. bool rmdir(const char* dir)
  57. {
  58.     return dir_operations(8, dir);
  59. }
  60.  
  61. bool mkdir(const char* dir)
  62. {
  63.     return dir_operations(9, dir);
  64. }
  65.