Subversion Repositories Kolibri OS

Rev

Rev 3434 | Rev 3444 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. // универсальность добавления /
  2.  
  3. :void copyf(dword from1, in1)
  4. {
  5.         dword error;
  6.         BDVK CopyFile_atr1;
  7.         if (!from1) || (!in1) { notify("Error: too less copyf params!"); notify(from1); notify(in1); return; }
  8.         error = GetFileInfo(from1, #CopyFile_atr1);
  9.         if (error)
  10.                 debug("Error: copyf->GetFileInfo");
  11.         else
  12.                 if (isdir(from1)) CopyFolder(from1, in1); else CopyFile(from1, in1);
  13. }
  14.  
  15. :int CopyFile(dword copy_from3, copy_in3)
  16. {
  17.         BDVK CopyFile_atr;
  18.         dword error, cbuf;
  19.         debug(copy_from3);
  20.         error = GetFileInfo(copy_from3, #CopyFile_atr);
  21.         if (error)
  22.                 {debug("Error: CopyFile->GetFileInfo"); debug(copy_from3);}
  23.         else
  24.         {
  25.                 cbuf = malloc(CopyFile_atr.sizelo);    
  26.                 error = ReadFile(0, CopyFile_atr.sizelo, cbuf, copy_from3);
  27.                 if (error)
  28.                         debug("Error: CopyFile->ReadFile");
  29.                 else
  30.                 {
  31.                         error = WriteFile(CopyFile_atr.sizelo, cbuf, copy_in3);
  32.                         if (error) debug("Error: CopyFile->WriteFile");
  33.                 }
  34.         }
  35.         free(cbuf);
  36.         if (error) debug(copy_from3);
  37.         return error;
  38. }
  39.  
  40. :void CopyFolder(dword from2, in2)
  41. {
  42.         dword dirbuf, fcount, filename;
  43.         int i, error, isdir;
  44.         char copy_from2[4096], copy_in2[4096];
  45.  
  46.         error = GetDir(#dirbuf, #fcount, from2);
  47.         if (error)
  48.         {
  49.                 debug("Error: CopyFolder->GetDir");
  50.                 debug_error(from2, error);
  51.                 debug_error(in2, error);
  52.                 free(dirbuf);
  53.                 return;
  54.         }
  55.        
  56.         if ((strcmp(in2, "/sys")!=0) && (strcmp(in2, "/tmp9/1")!=0))
  57.         {
  58.                 error = CreateDir(in2);
  59.                 if (error) debug_error(in2, error);
  60.         }
  61.         chrcat(in2, '/');
  62.         chrcat(from2, '/');
  63.  
  64.         for (i=0; i<fcount; i++)
  65.         {
  66.                 filename = i*304+dirbuf+72;
  67.                 isdir = TestBit(ESDWORD[filename-40], 4);
  68.                 if (isdir)
  69.                 {
  70.                         if ( (!strcmp(filename, ".")) || (!strcmp(filename, "..")) ) continue;
  71.                         strcpy(#copy_from2, from2);
  72.                         strcpy(#copy_in2, in2);
  73.                         strcat(#copy_from2, filename);
  74.                         strcat(#copy_in2, filename);
  75.  
  76.                         CopyFolder(#copy_from2, #copy_in2);
  77.                 }
  78.                 else
  79.                 {
  80.                         strcpy(#copy_from2, from2);
  81.                         strcat(#copy_from2, filename);
  82.                         strcpy(#copy_in2, in2);
  83.                         strcat(#copy_in2, filename);
  84.  
  85.                         copyf_Action(filename);
  86.  
  87.                         if (CopyFile(#copy_from2, #copy_in2)!=0) CopyFile(#copy_from2, #copy_in2); // #2 :)
  88.                 }
  89.         }
  90.         free(dirbuf);
  91. }
  92.  
  93.  
  94. unsigned char *ERROR_TEXT[]={
  95. "Code #0 - No error",
  96. "Error #1 - Base or partition of a hard disk is not defined",
  97. "Error #2 - Function isn't supported for this file system",
  98. "Error #3 - Unknown file system",
  99. "Error #4 - Reserved, is never returned",
  100. "Error #5 - File or folder not found",
  101. "Error #6 - End of file, EOF",
  102. "Error #7 - Pointer lies outside of application memory",
  103. "Error #8 - Too less disk space",
  104. "Error #9 - FAT table is destroyed",
  105. "Error #10 - Access denied",
  106. "Error #11 - Device error",
  107. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  108. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  109. "Error #30 - Not enough memory",
  110. "Error #31 - File is not executable",
  111. "Error #32 - Too many processes",
  112. 0};
  113.  
  114. :dword get_error(int N)
  115. {
  116.         char error[256];  
  117.         N = fabs(N);
  118.         if (N<=33)
  119.         {
  120.                 strcpy(#error, ERROR_TEXT[N]);
  121.         }
  122.         else
  123.         {
  124.                 strcpy(#error, itoa(N));
  125.                 strcat(#error, " - Unknown error number O_o");
  126.         }
  127.         return #error;
  128. }
  129.  
  130. :void debug_error(dword path, error_number)
  131. {
  132.         if (path) debug(path);
  133.         debug(get_error(error_number));
  134. }