Subversion Repositories Kolibri OS

Rev

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

  1. struct f70{
  2.         dword   func;
  3.         dword   param1;
  4.         dword   param2;
  5.         dword   param3;
  6.         dword   param4;
  7.         char    rezerv;
  8.         dword   name;
  9. };
  10.  
  11. struct BDVK{
  12.         dword   attr;
  13.         byte    type_name;
  14.         byte    rez1, rez2, rez3;
  15.         dword   timecreate;
  16.         dword   datecreate;
  17.         dword   timelastaccess;
  18.         dword   datelastaccess;
  19.         dword   timelastedit;
  20.         dword   datelastedit;
  21.         dword   sizelo;
  22.         dword   sizehi;
  23.         char    name[518];
  24. };
  25.  
  26.  
  27. ///////////////////////////
  28. //   Çàïóñê ïðîãðàììû    //
  29. ///////////////////////////
  30. f70 run_file_70;
  31. signed int RunProgram(dword run_path, run_param)
  32. {      
  33.     run_file_70.func = 7;
  34.     run_file_70.param1 =
  35.     run_file_70.param3 =
  36.     run_file_70.param4 =
  37.     run_file_70.rezerv = 0;
  38.     run_file_70.param2 = run_param;
  39.     run_file_70.name = run_path;
  40.     $mov eax,70
  41.     $mov ebx,#run_file_70.func
  42.     $int 0x40
  43. }
  44.  
  45. ///////////////////////////
  46. //    Ñîçäàíèå ïàïêè     //
  47. ///////////////////////////
  48. f70 create_dir_70;
  49. :int CreateDir(dword new_folder_path)
  50. {
  51.         create_dir_70.func = 9;
  52.         create_dir_70.param1 =
  53.         create_dir_70.param2 =
  54.         create_dir_70.param3 =
  55.         create_dir_70.param4 =
  56.         create_dir_70.rezerv = 0;
  57.         create_dir_70.name = new_folder_path;
  58.         $mov eax,70
  59.         $mov ebx,#create_dir_70.func
  60.         $int 0x40
  61. }
  62.  
  63. ////////////////////////////
  64. //  Óäàëåíèå ôàéëà/ïàïêè  //
  65. ////////////////////////////
  66. f70 del_file_70;       
  67. :int DeleteFile(dword del_file_path)
  68. {    
  69.         del_file_70.func = 8;
  70.         del_file_70.param1 =
  71.         del_file_70.param2 =
  72.         del_file_70.param3 =
  73.         del_file_70.param4 =
  74.         del_file_70.rezerv = 0;
  75.         del_file_70.name = del_file_path;
  76.         $mov eax,70
  77.         $mov ebx,#del_file_70.func
  78.         $int 0x40
  79. }
  80.  
  81. ////////////////////////////
  82. //     Ïðî÷èòàòü ôàéë     //
  83. ////////////////////////////
  84. f70 read_file_70;
  85. :int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
  86. {
  87.         read_file_70.func = 0;
  88.         read_file_70.param1 = read_pos;
  89.         read_file_70.param2 = 0;
  90.         read_file_70.param3 = read_file_size;
  91.         read_file_70.param4 = read_buffer;
  92.         read_file_70.rezerv = 0;
  93.         read_file_70.name = read_file_path;
  94.         $mov eax,70
  95.         $mov ebx,#read_file_70.func
  96.         $int 0x40
  97. }
  98.  
  99. :int GetFile(dword buf, filesize, read_path)
  100. {
  101.         BDVK ReadFile_atr;
  102.         dword rBuf;
  103.         if (! GetFileInfo(read_path, #ReadFile_atr))
  104.         {
  105.                 rBuf = malloc(ReadFile_atr.sizelo);    
  106.                 if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
  107.                 {
  108.                         ESDWORD[buf] = rBuf;
  109.                         ESDWORD[filesize] = ReadFile_atr.sizelo;
  110.                         return 1;
  111.                 }
  112.         }
  113.         free(rBuf);
  114.         return 0;
  115. }
  116.  
  117.  
  118. ////////////////////////////
  119. //     Çàïèñàòü ôàéë      //
  120. ////////////////////////////
  121. f70 write_file_70;
  122. :int WriteFile(dword write_file_size, write_buffer, write_file_path)
  123. {
  124.         write_file_70.func = 2;
  125.         write_file_70.param1 = 0;
  126.         write_file_70.param2 = 0;
  127.         write_file_70.param3 = write_file_size;
  128.         write_file_70.param4 = write_buffer;
  129.         write_file_70.rezerv = 0;
  130.         write_file_70.name = write_file_path;
  131.         $mov eax,70
  132.         $mov ebx,#write_file_70.func
  133.         $int 0x40
  134. }      
  135.  
  136. ///////////////////////////
  137. //    Ïðî÷èòàòü ïàïêó    //
  138. ///////////////////////////
  139. f70 read_dir_70;
  140. :int ReadDir(dword file_count, read_buffer, dir_path)
  141. {
  142.         read_dir_70.func = 1;
  143.         read_dir_70.param1 =
  144.         read_dir_70.param2 =
  145.         read_dir_70.rezerv = 0;
  146.         read_dir_70.param3 = file_count;
  147.         read_dir_70.param4 = read_buffer;
  148.         read_dir_70.name = dir_path;
  149.         $mov eax,70
  150.         $mov ebx,#read_dir_70.func
  151.         $int 0x40
  152. }
  153.  
  154.  
  155. :int GetDir(dword dir_buf, file_count, path)
  156. {
  157.         dword buf, fcount, error;
  158.         ESDWORD[file_count] = 0;
  159.         buf = malloc(32);
  160.         error = ReadDir(0, buf, path);
  161.         if (!error)
  162.         {
  163.                 fcount = ESDWORD[buf+8];
  164.                 buf = realloc(buf, fcount+1*304+32);
  165.                 ReadDir(fcount, buf, path);
  166.                 if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
  167.                 if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
  168.                 ESDWORD[dir_buf] = buf;
  169.                 ESDWORD[file_count] = fcount;
  170.         }
  171.         return error;
  172. }
  173.  
  174.  
  175. ///////////////////////////
  176. //   Ïàðàìåòðû ôàéëà    //
  177. ///////////////////////////
  178. f70 getinfo_file_70;
  179. :dword GetFileInfo(dword file_path, bdvk_struct)
  180. {    
  181.     getinfo_file_70.func = 5;
  182.     getinfo_file_70.param1 =
  183.     getinfo_file_70.param2 =
  184.     getinfo_file_70.param3 = 0;
  185.     getinfo_file_70.param4 = bdvk_struct;
  186.     getinfo_file_70.rezerv = 0;
  187.     getinfo_file_70.name = file_path;
  188.     $mov eax,70
  189.     $mov ebx,#getinfo_file_70.func
  190.     $int 0x40
  191. }
  192.  
  193.  
  194. ///////////////////////////
  195. //   Ñêîïèðîâàòü ôàéë    //
  196. ///////////////////////////
  197. :int CopyFile(dword copy_from, copy_in)
  198. {
  199.         BDVK CopyFile_atr;
  200.         dword cBufer=0;
  201.         char rezult = -1;
  202.         if (! GetFileInfo(copy_from, #CopyFile_atr))
  203.         {
  204.                 cBufer = malloc(CopyFile_atr.sizelo);  
  205.                 if (! ReadFile(0, CopyFile_atr.sizelo, cBufer, copy_from))
  206.                 {
  207.                         rezult = WriteFile(CopyFile_atr.sizelo, cBufer, copy_in);
  208.                 }
  209.         }
  210.         free(cBufer);
  211.         return rezult;
  212. }
  213.  
  214. inline fastcall void SetCurDir( ECX)
  215. {
  216.     $mov eax,30
  217.     $mov ebx,1
  218.     $int 0x40
  219. }
  220.  
  221. inline fastcall void GetCurDir( ECX, EDX)
  222. {
  223.     $mov eax,30
  224.     $mov ebx,2
  225.     $int 0x40
  226. }
  227.  
  228. void notify(dword notify_param)
  229. {
  230.         RunProgram("@notify", notify_param);
  231. }
  232.  
  233. :dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
  234. {
  235.         char absolute_path[4096];
  236.         strcpy(#absolute_path, #program_path);
  237.         absolute_path[strrchr(#absolute_path, '/')] = '\0';
  238.         strcat(#absolute_path, relative_path);
  239.         return #absolute_path;
  240. }
  241.