objinc.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {---------------------------------------------------------------------------}
  2. { FileClose -> Platforms DOS - Not checked }
  3. {---------------------------------------------------------------------------}
  4. FUNCTION FileClose (Handle: THandle): Word;
  5. var
  6. regs : trealregs;
  7. begin
  8. regs.realebx:=handle;
  9. regs.realeax:=$3e00;
  10. sysrealintr($21,regs);
  11. FileClose := 0;
  12. end;
  13. {---------------------------------------------------------------------------}
  14. { FileOpen -> Platforms DOS - Checked 05May1998 CEC }
  15. { Returns 0 on failure }
  16. {---------------------------------------------------------------------------}
  17. FUNCTION FileOpen (Var FileName: AsciiZ; Mode: Word): THandle;
  18. Var
  19. var regs : trealregs;
  20. BEGIN
  21. DosStreamError:=0;
  22. syscopytodos(longint(@FileName),256);
  23. { get linear address from system unit }
  24. regs.realedx:=tb mod 16;
  25. regs.realds:=tb div 16;
  26. regs.realeax := Mode;
  27. regs.realecx:=0;
  28. sysrealintr($21,regs);
  29. if (regs.realflags and 1) <> 0 then
  30. begin
  31. InOutRes:=lo(regs.realeax);
  32. FileOpen:=$0;
  33. exit;
  34. end
  35. else
  36. { word handle (under DOS) }
  37. FileOpen:=regs.realeax and $ffff;
  38. END;
  39. {---------------------------------------------------------------------------}
  40. { FileWrite -> Platforms DOS - Checked 05May1998 CEC }
  41. {---------------------------------------------------------------------------}
  42. FUNCTION FileWrite (Handle: THandle; Var Buf; Count: Sw_Word; Var Actual: Sw_Word): Word;
  43. BEGIN
  44. system.do_write(longint(Handle),longint(@Buf),Count);
  45. Actual:=Count;
  46. FileWrite:=InOutRes;
  47. End;
  48. {---------------------------------------------------------------------------}
  49. { SetFileSize -> Platforms DOS - Not Checked }
  50. {---------------------------------------------------------------------------}
  51. FUNCTION SetFileSize (Handle: THandle; FileSize: LongInt): Word;
  52. VAR Actual, Buf: LongInt;
  53. BEGIN
  54. If (Actual = FileSize) Then Begin { No position error }
  55. Actual := FileWrite(Handle, Pointer(@Buf), 0,Actual); { Truncate the file }
  56. If (Actual <> -1) Then SetFileSize := 0 Else { No truncate error }
  57. SetFileSize := 103; { File truncate error }
  58. End Else SetFileSize := 103; { File truncate error }
  59. END;
  60. {---------------------------------------------------------------------------}
  61. { FileRead -> Platforms DOS - Checked 05May1998 CEC }
  62. {---------------------------------------------------------------------------}
  63. FUNCTION FileRead (Handle: THandle; Var Buf; Count: Sw_Word;
  64. Var Actual: Sw_Word): Word;
  65. BEGIN
  66. Actual:=system.do_read(longint(Handle),longint(@Buf),Count);
  67. FileRead:=InOutRes;
  68. End;
  69. {***************************************************************************}
  70. { DosSetFilePtr -> Platforms DOS - Checked 05May1998 CEC }
  71. {***************************************************************************}
  72. {=DosSetFilePtr======================================================
  73. Calls the operating system to move the file denoted by the handle to
  74. to the requested position. The move method can be: 0 = absolute offset;
  75. 1 = offset from present location; 2 = offset from end of file;
  76. Any error is held in DosErrorStream and returned from the call.
  77. If the return is zero (ie no error) NewPos contains the new absolute
  78. file position.
  79. -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB}
  80. FUNCTION SetFilePos (Handle: THandle; Pos: LongInt; MoveType: Word;
  81. Var Actual: LongInt): Word;
  82. Var
  83. regs: Trealregs;
  84. const
  85. CarryFlag = $001;
  86. BEGIN
  87. regs.realeax := ($42 shl 8) + Byte(MoveType);
  88. { regs.realah := $42;
  89. regs.realal := Byte(MoveType); }
  90. regs.realedx := pos and $ffff; { keep low word }
  91. regs.realecx := pos shr 16;
  92. regs.realebx := longint(Handle);
  93. sysrealintr($21,regs);
  94. if (regs.RealFlags and CarryFlag = 0) then { no error }
  95. Actual:=(regs.realeax and $ffff) + ((regs.realedx and $ffff) shl 16)
  96. else
  97. DosStreamError:=word(regs.realeax);
  98. SetFilePos := DosStreamError; { Return any error }
  99. END;