Subversion Repositories Kolibri OS

Rev

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