Subversion Repositories Kolibri OS

Rev

Rev 5542 | 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 date
  12. {
  13.         byte day;
  14.         byte month;
  15.         word year;
  16. };
  17.  
  18. :struct BDVK {
  19.         dword   readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0;
  20.         byte    type_name;
  21.         byte    rez1, rez2, selected;
  22.         dword   timecreate;
  23.         date    datecreate;
  24.         dword   timelastaccess;
  25.         date    datelastaccess;
  26.         dword   timelastedit;
  27.         date    datelastedit;
  28.         dword   sizelo;
  29.         dword   sizehi;
  30.         char    name[518];
  31. };
  32.  
  33.  
  34. :void DrawDate(dword x, y, color, dword in_date)
  35. {
  36.         EDI = in_date;
  37.         EAX = 47;
  38.         EBX = 2<<16;
  39.         EDX = x<<16+y;
  40.         ESI = 0x80<<24+color;
  41.         ECX = EDI.date.day;
  42.         $int 0x40;
  43.         EDX += 18<<16;
  44.         ECX = EDI.date.month;
  45.         $int 0x40;
  46.         EDX += 18<<16;
  47.         EBX = 4<<16;
  48.         ECX = EDI.date.year;
  49.         $int 0x40;
  50. }
  51.  
  52.  
  53. ///////////////////////////
  54. //   Ïàðàìåòðû ôàéëà    //
  55. ///////////////////////////
  56. :f70 getinfo_file_70;
  57. :dword GetFileInfo(dword file_path, bdvk_struct)
  58. {    
  59.     getinfo_file_70.func = 5;
  60.     getinfo_file_70.param1 =
  61.     getinfo_file_70.param2 =
  62.     getinfo_file_70.param3 = 0;
  63.     getinfo_file_70.param4 = bdvk_struct;
  64.     getinfo_file_70.rezerv = 0;
  65.     getinfo_file_70.name = file_path;
  66.     $mov eax,70
  67.     $mov ebx,#getinfo_file_70.func
  68.     $int 0x40
  69. }
  70.  
  71. ///////////////////////////
  72. //   Èçìåíåíèå ïàðàìåòðîâ ôàéëà    //
  73. ///////////////////////////
  74. :f70 setinfo_file_70;
  75. :dword SetFileInfo(dword file_path, bdvk_struct)
  76. {    
  77.     setinfo_file_70.func = 6;
  78.     setinfo_file_70.param1 =
  79.     setinfo_file_70.param2 =
  80.     setinfo_file_70.param3 = 0;
  81.     setinfo_file_70.param4 = bdvk_struct;
  82.     setinfo_file_70.rezerv = 0;
  83.     setinfo_file_70.name = file_path;
  84.     $mov eax,70
  85.     $mov ebx,#setinfo_file_70.func
  86.     $int 0x40
  87. }
  88.  
  89. ///////////////////////////
  90. //   Çàïóñê ïðîãðàììû    //
  91. ///////////////////////////
  92. :f70 run_file_70;
  93. :signed int RunProgram(dword run_path, run_param)
  94. {      
  95.     run_file_70.func = 7;
  96.     run_file_70.param1 =
  97.     run_file_70.param3 =
  98.     run_file_70.param4 =
  99.     run_file_70.rezerv = 0;
  100.     run_file_70.param2 = run_param;
  101.     run_file_70.name = run_path;
  102.     $mov eax,70
  103.     $mov ebx,#run_file_70.func
  104.     $int 0x40
  105. }
  106.  
  107. ///////////////////////////
  108. //    Ñîçäàíèå ïàïêè     //
  109. ///////////////////////////
  110. :f70 create_dir_70;
  111. :int CreateDir(dword new_folder_path)
  112. {
  113.         create_dir_70.func = 9;
  114.         create_dir_70.param1 =
  115.         create_dir_70.param2 =
  116.         create_dir_70.param3 =
  117.         create_dir_70.param4 =
  118.         create_dir_70.rezerv = 0;
  119.         create_dir_70.name = new_folder_path;
  120.         $mov eax,70
  121.         $mov ebx,#create_dir_70.func
  122.         $int 0x40
  123. }
  124.  
  125. ////////////////////////////
  126. //  Óäàëåíèå ôàéëà/ïàïêè  //
  127. ////////////////////////////
  128. :f70 del_file_70;      
  129. :int DeleteFile(dword del_file_path)
  130. {    
  131.         del_file_70.func = 8;
  132.         del_file_70.param1 =
  133.         del_file_70.param2 =
  134.         del_file_70.param3 =
  135.         del_file_70.param4 =
  136.         del_file_70.rezerv = 0;
  137.         del_file_70.name = del_file_path;
  138.         $mov eax,70
  139.         $mov ebx,#del_file_70.func
  140.         $int 0x40
  141. }
  142.  
  143. ////////////////////////////
  144. //     Ïðî÷èòàòü ôàéë     //
  145. ////////////////////////////
  146. :f70 read_file_70;
  147. :int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
  148. {
  149.         read_file_70.func = 0;
  150.         read_file_70.param1 = read_pos;
  151.         read_file_70.param2 = 0;
  152.         read_file_70.param3 = read_file_size;
  153.         read_file_70.param4 = read_buffer;
  154.         read_file_70.rezerv = 0;
  155.         read_file_70.name = read_file_path;
  156.         $mov eax,70
  157.         $mov ebx,#read_file_70.func
  158.         $int 0x40
  159. }
  160.  
  161. ////////////////////////////
  162. //     Çàïèñàòü ôàéë      //
  163. ////////////////////////////
  164. :f70 write_file_70;
  165. :int WriteFile(dword write_file_size, write_buffer, write_file_path)
  166. {
  167.         write_file_70.func = 2;
  168.         write_file_70.param1 = 0;
  169.         write_file_70.param2 = 0;
  170.         write_file_70.param3 = write_file_size;
  171.         write_file_70.param4 = write_buffer;
  172.         write_file_70.rezerv = 0;
  173.         write_file_70.name = write_file_path;
  174.         $mov eax,70
  175.         $mov ebx,#write_file_70.func
  176.         $int 0x40
  177. }
  178.  
  179. //////////////////////////////////////////
  180. //     WriteInFileThatAlredyExists      //
  181. //////////////////////////////////////////
  182. :f70 write_file_offset_70;
  183. :int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset)
  184. {
  185.         write_file_offset_70.func = 3;
  186.         write_file_offset_70.param1 = offset;
  187.         write_file_offset_70.param2 = 0;
  188.         write_file_offset_70.param3 = write_data_size;
  189.         write_file_offset_70.param4 = write_buffer;
  190.         write_file_offset_70.rezerv = 0;
  191.         write_file_offset_70.name = write_file_path;
  192.         $mov eax,70
  193.         $mov ebx,#write_file_offset_70.func
  194.         $int 0x40
  195. }  
  196.  
  197. ///////////////////////////
  198. //    Ïðî÷èòàòü ïàïêó    //
  199. ///////////////////////////
  200. :f70 read_dir_70;
  201. :int ReadDir(dword file_count, read_buffer, dir_path)
  202. {
  203.         read_dir_70.func = 1;
  204.         read_dir_70.param1 =
  205.         read_dir_70.param2 =
  206.         read_dir_70.rezerv = 0;
  207.         read_dir_70.param3 = file_count;
  208.         read_dir_70.param4 = read_buffer;
  209.         read_dir_70.name = dir_path;
  210.         $mov eax,70
  211.         $mov ebx,#read_dir_70.func
  212.         $int 0x40
  213. }
  214.  
  215. :char isdir(dword fpath)
  216. {
  217.         BDVK fpath_atr;
  218.         GetFileInfo(fpath, #fpath_atr);
  219.         return fpath_atr.isfolder;
  220. }
  221.  
  222. :int GetFile(dword buf, filesize, read_path)
  223. {
  224.         BDVK ReadFile_atr;
  225.         dword rBuf;
  226.         if (! GetFileInfo(read_path, #ReadFile_atr))
  227.         {
  228.                 rBuf = malloc(ReadFile_atr.sizelo);    
  229.                 if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
  230.                 {
  231.                         ESDWORD[buf] = rBuf;
  232.                         ESDWORD[filesize] = ReadFile_atr.sizelo;
  233.                         return 1;
  234.                 }
  235.         }
  236.         free(rBuf);
  237.         return 0;
  238. }
  239.  
  240. enum
  241. {
  242.         DIRS_ALL,
  243.         DIRS_NOROOT,
  244.         DIRS_ONLYREAL
  245. };
  246. :int GetDir(dword dir_buf, file_count, path, doptions)
  247. {
  248.         dword buf, fcount, error;
  249.         buf = malloc(32);
  250.         error = ReadDir(0, buf, path);
  251.         if (!error)
  252.         {
  253.                 fcount = ESDWORD[buf+8];
  254.                 buf = realloc(buf, fcount+1*304+32);
  255.                 ReadDir(fcount, buf, path);
  256.                 //fcount=EBX;
  257.  
  258.                 if (doptions == DIRS_ONLYREAL)
  259.                 {
  260.                         if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
  261.                         if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
  262.                 }
  263.                 if (doptions == DIRS_NOROOT)
  264.                 {
  265.                         if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
  266.                 }
  267.  
  268.                 ESDWORD[dir_buf] = buf;
  269.                 ESDWORD[file_count] = fcount;
  270.         }
  271.         else
  272.         {
  273.                 ESDWORD[file_count] = 0;
  274.                 ESDWORD[dir_buf] = free(buf);
  275.         }
  276.         return error;
  277. }
  278.  
  279. :dword notify(dword notify_param)
  280. {
  281.         return RunProgram("@notify", notify_param);
  282. }
  283.  
  284. :dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
  285. {
  286.         char absolute_path[4096];
  287.         if (ESBYTE[relative_path]=='/')
  288.         {
  289.                 strcpy(#absolute_path, relative_path);
  290.         }
  291.         else
  292.         {
  293.                 strcpy(#absolute_path, #program_path);
  294.                 absolute_path[strrchr(#absolute_path, '/')] = '\0';
  295.                 strcat(#absolute_path, relative_path);
  296.         }
  297.         return #absolute_path;
  298. }
  299.  
  300. :dword ConvertSize(unsigned int bytes)
  301. {
  302.   unsigned char size_prefix[8], size_nm[4];
  303.   if (bytes>=1073741824) strcpy(#size_nm, " Gb");
  304.   else if (bytes>=1048576) strcpy(#size_nm, " Mb");
  305.   else if (bytes>=1024) strcpy(#size_nm, " Kb");
  306.   else strcpy(#size_nm, " b ");
  307.   while (bytes>1023) bytes/=1024;
  308.   itoa_(#size_prefix, bytes);
  309.   strcat(#size_prefix, #size_nm);
  310.   return #size_prefix;
  311. }
  312.  
  313. :dword ConvertSizeToKb(unsigned int bytes)
  314. {
  315.         unsigned char size[25]=0;
  316.         unsigned int kb;
  317.         dword kb_line;
  318.  
  319.         kb_line = itoa(bytes / 1024);
  320.         strcpy(#size, kb_line);
  321.         strcat(#size, " Kb");
  322.  
  323.         return #size;
  324. }