Subversion Repositories Kolibri OS

Rev

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