Subversion Repositories Kolibri OS

Rev

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

  1. {cp866}
  2.  
  3. function DecodeErrNo(ErrNo: DWord): Word;
  4. {0 = ãᯥ譮
  5.  1 = ­¥ ®¯à¥¤¥«¥­  ¡ §  ¨/¨«¨ à §¤¥« ¦ñá⪮£® ¤¨áª  (¯®¤äã­ªæ¨ï¬¨ 7, 8 ä㭪樨 21)
  6.  2 = äã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë
  7.  3 = ­¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬ 
  8.  4 = § à¥§¥à¢¨à®¢ ­®, ­¨ª®£¤  ­¥ ¢®§¢à é ¥âáï ¢ ⥪ã饩 ॠ«¨§ æ¨¨
  9.  5 = ä ©« ­¥ ­ ©¤¥­
  10.  6 = ä ©« § ª®­ç¨«áï
  11.  7 = 㪠§ â¥«ì ¢­¥ ¯ ¬ï⨠¯à¨«®¦¥­¨ï
  12.  8 = ¤¨áª § ¯®«­¥­
  13.  9 = â ¡«¨æ  FAT à §àã襭 
  14.  10 = ¤®áâ㯠§ ¯à¥éñ­
  15.  11 = ®è¨¡ª  ãáâனá⢠}
  16. begin
  17.   case ErrNo of
  18.     0: Result := 0;
  19.     1: Result := 152;
  20.     2: Result := 153;
  21.     3: Result := 151;
  22.     4: Result := 1;
  23.     5: Result := 2;
  24.     6: Result := 0;
  25.     8: Result := 101;
  26.   else
  27.     Result := 153; { Unknown command (­¥¨§¢¥áâ­ ï ª®¬ ­¤ ) }
  28.   end;
  29. end;
  30.  
  31. function do_isdevice(handle:thandle): Boolean;
  32. begin
  33.   InOutRes := 211;
  34.   Result := False;
  35. end;
  36.  
  37. procedure do_close(handle: THandle);
  38. begin
  39.   FreeMem(PKosFile(handle));
  40.   InOutRes := 0;
  41. end;
  42.  
  43. procedure do_erase(p : pchar);
  44. begin
  45.   InOutRes := 211;
  46. end;
  47.  
  48. procedure do_rename(p1,p2 : pchar);
  49. begin
  50.   InOutRes := 211;
  51. end;
  52.  
  53. function do_write(handle: THandle; addr: Pointer; len: Longint): Longint;
  54. begin
  55.   PKosFile(handle)^.Size := len;
  56.   PKosFile(handle)^.Data := addr;
  57.   InOutRes := DecodeErrNo(kos_writefile(PKosFile(handle), Result));
  58.   Inc(PKosFile(handle)^.Position, Result);
  59. end;
  60.  
  61. function do_read(handle: THandle; addr: Pointer; len: Longint): Longint;
  62. begin
  63.   PKosFile(handle)^.Size := len;
  64.   PKosFile(handle)^.Data := addr;
  65.   InOutRes := DecodeErrNo(kos_readfile(PKosFile(handle), Result));
  66.   Inc(PKosFile(handle)^.Position, Result);
  67. end;
  68.  
  69. function do_filepos(handle: THandle): Int64;
  70. begin
  71.   Result := PKosFile(handle)^.Position;
  72. end;
  73.  
  74. procedure do_seek(handle: THandle; pos: Int64);
  75. begin
  76.   PKosFile(handle)^.Position := pos;
  77. end;
  78.  
  79. function do_seekend(handle: THandle): Int64;
  80. begin
  81.   InOutRes := 211;
  82.   Result := 0;
  83. end;
  84.  
  85. function do_filesize(handle: THandle): Int64;
  86. var
  87.   BDFE: TKosBDFE;
  88. begin
  89.   PKosFile(handle)^.Data := @BDFE;
  90.   InOutRes := DecodeErrNo(kos_fileinfo(PKosFile(handle)));
  91.   Result := BDFE.Size;
  92. end;
  93.  
  94. procedure do_truncate(handle: THandle; pos: Int64);
  95. begin
  96.   InOutRes := 211;
  97. end;
  98.  
  99. procedure do_open(var f; p: PChar; flags: Longint);
  100. var
  101.   KosFile: PKosFile;
  102.   FilePath: PChar;
  103.   FilePathLen: Longint;
  104.   RecSize: Longint;
  105.   CurrDir: array[0..2048] of Char;
  106.   CurrDirLen: Longint;
  107. begin
  108.   case flags and 3 of
  109.     0: FileRec(f).Mode := fmInput;
  110.     1: FileRec(f).Mode := fmOutput;
  111.     2: FileRec(f).Mode := fmInOut;
  112.   end;
  113.  
  114.   {”®à¬¨à®¢ ­¨¥ ¨¬¥­¨  ¡á®«îâ­®£® ¯ãâ¨}
  115.   FilePathLen := Length(p);
  116.   if p^ <> DirectorySeparator then
  117.   begin
  118.     {XXX: à §¬¥à ¡ãä¥à  CurrDir ¬®¦¥â ®ª § âìáï ­¥¤®áâ â®ç­ë¬}
  119.     CurrDirLen := kos_getdir(@CurrDir, SizeOf(CurrDir) - FilePathLen - 1) - 1;
  120.     FilePath := @CurrDir;
  121.  
  122.     if FilePath[CurrDirLen - 1] <> DirectorySeparator then
  123.     begin
  124.       FilePath[CurrDirLen] := DirectorySeparator;
  125.       Inc(CurrDirLen);
  126.     end;
  127.     Move(p^, FilePath[CurrDirLen], FilePathLen + 1);
  128.     Inc(FilePathLen, CurrDirLen);
  129.   end else
  130.     FilePath := p;
  131.  
  132.   {‘®§¤ ­¨¥ áâàãªâãàë TKosFile}
  133.   RecSize := SizeOf(TKosFile) + FilePathLen;
  134.   KosFile := GetMem(RecSize);
  135.   FillChar(KosFile^, RecSize, 0);
  136.   Move(FilePath^, KosFile^.Name, FilePathLen);
  137.   FileRec(f).Handle := DWord(KosFile);
  138.  
  139.   if flags and $1000 <> 0 then
  140.   begin
  141.     { ᮧ¤ âì ä ©« }
  142.     InOutRes := DecodeErrNo(kos_rewritefile(KosFile, RecSize));
  143.   end else
  144.     InOutRes := 0;
  145. end;
  146.