[fp] changes in rtl & examples

git-svn-id: svn://kolibrios.org@790 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
bw 2008-04-12 09:48:18 +00:00
parent 2dae596c61
commit 350d7e1cc7
15 changed files with 204 additions and 102 deletions

View File

@ -0,0 +1,42 @@
[target]
programs=example ray
[default]
target=win32
cpu=i386
[compiler]
options=-dKOLIBRI
unittargetdir=build
targetdir=bin
sourcedir=src
[prerules]
ifdef KFPCDIR
override KFPCDIR:=$(subst \,/,$(KFPCDIR))
ifeq ($(wildcard $(KFPCDIR)/bin),)
override KFPCDIR=wrong
endif
else
override KFPCDIR=wrong
endif
ifeq ($(KFPCDIR),wrong)
$(error The KFPCDIR environment is wrong)
endif
#UNITSDIR:=$(wildcard $(FPCDIR)/units/$(CPU_TARGET)-kolibri)
UNITSDIR:=$(wildcard $(KFPCDIR)/units)
KOSEXT=.kex
EXE2KEX=$(KFPCDIR)/bin/exe2kos
[rules]
ifneq ($(TARGET_PROGRAMS),)
KOSFILES=$(addsuffix $(KOSEXT),$(TARGET_PROGRAMS))
endif
fpc_all: $(KOSFILES)
%$(KOSEXT): %$(EXEEXT)
@$(EXE2KEX) $(COMPILER_TARGETDIR)/$^ $(COMPILER_TARGETDIR)/$@
@$(DEL) $(COMPILER_TARGETDIR)/$^

View File

@ -1,21 +0,0 @@
@echo off
set NAME=%1
set NAMEEXE=%NAME%.exe
set NAMEKEX=%NAME%.kex
set BUILD=-FUbuild
set UNTS=-Fu..\units
fpc %NAME%.pp -n -Twin32 -Se5 -XXs -Sg -O3pPENTIUM3 -CfSSE -WB0 %BUILD% %UNTS%
if errorlevel 1 goto error
..\exe2kos\exe2kos.exe %NAMEEXE% %NAMEKEX%
del %NAMEEXE%
move %NAMEKEX% bin
goto end
:error
echo An error occured while building %NAME%
:end

View File

@ -1 +0,0 @@
@_build example

View File

@ -1 +0,0 @@
@call _build.bat ray

View File

@ -1 +1,21 @@
„«ï ­ ç «  ­¥®¡å®¦¨¬® ᮡà âì RTL ¨ ã⨫¨âã exe2kos. „«ï ­ ç «  ­¥®¡å®¦¨¬® ᮡà âì RTL (../rtl/build.sh ¨«¨ ..\rtl\build.bat) ¨
ã⨫¨âã exe2kos (../utils/exe2kos/build.sh ¨«¨ ..\utils\exe2kos\exe2kos.bat).
“¡¥¤¨â¥áì çâ®, ®â­®á¨â¥«ì­® ¤ ­­®© ¯ ¯ª¨, áãé¥áâ¢ãîâ ä ©« ../bin/exe2kos ¤«ï
Linux ¨«¨ ..\bin\exe2kos.exe ¤«ï Windows. ’ ª ¦¥ ã¡¥¤¨â¥áì çâ® áãé¥áâ¢ã¥â ­¥
¯ãáâ ï ¤¨à¥ªâ®à¨ï ../units/rtl ¤«ï Linux ¨«¨ ..\units\rtl ¤«ï Windows.
<EFBFBD>¥à¥¬¥­­ ï ®ªà㦥­¨ï FPCDIR ¤®«¦­  㪠§ë¢ âì ­  ¯ ¯ªã á FreePascal (¯ãâì
㪠§ë¢ ¥âáï ¡¥§ § ¢¥àè î饣® á«íè  ¨«¨ ®¡à â­®£® á«íè ).
<EFBFBD>¥à¥¬¥­­ ï ®ªà㦥­¨ï KFPCDIR ¤®«¦­  㪠§ë¢ âì ­  ¯ ¯ªã á ¯à®¥ªâ®¬ KolibriOS
FreePascal (¯ãâì 㪠§ë¢ ¥âáï ¡¥§ § ¢¥àè î饣® á«íè  ¨«¨ ®¡à â­®£® á«íè ). í⮩
¯ ¯ª¥ ¤®«¦­ë ­ å®¤¨âìáï â ª¨¥ ¤¨à¥ªâ®à¨¨: bin, examples, rtl, units, utils.
<EFBFBD>®á«¥ í⮣® ¢ë¯®«­¨â¥ á«¥¤ãî騥 ª®¬ ­¤ë ¢ ¤ ­­®© ¯ ¯ª¥ (¡¥§ §­ ª  $ ¨ ¯à®¡¥« 
¯®á«¥ ­¥£®):
$ fpcmake -Twin32
$ make
…᫨ ¢ë ¢á¥ ᤥ« ¨ ¯à ¢¨«ì­®, â® ¢ ¯ ¯ª¥ bin ¯®ï¢ïâáï ¨á¯®«­ï¥¬ë¥ ä ©«ë á
à áè¨à¥­¨¥¬ kex.
build - ¢à¥¬¥­­ ï ¯ ¯ª , ¨á¯®«ì§ã¥¬ ï ¯à¨ ᡮથ, ¬®¦¥â¥ 㤠«¨âì ¥ñ.

View File

@ -4,37 +4,36 @@
{$mode objfpc} {$mode objfpc}
{$smartlink on} {$smartlink on}
{$apptype console} {$apptype gui}
{ <EFBFBD>  ¤ ­­ë© ¬®¬¥­â à áᬠâਢ ¥âáï ¢ë¯®«­¥­¨¥ ¯à¨«®¤¥­¨ï ⮫쪮 ª ª ª®­á®«ì­®¥,
â.¥. ¤¨à¥ªâ¨¢  console ®¡ï§ â¥«ì­ , ¯®¢¥¤¥­¨¥ ¯à®£à ¬¬ë ¯à¨ ®âáãâá⢨¨ í⮩
¤¨à¥ªâ¨¢ë ¯à¥¤®¯à¥¤¥«¨âì ­¥«ì§ï. ƒ à ­â¨à®¢ ­­® ­¥«ì§ï ¨á¯®«ì§®¢ âì ä㭪樨
Write, WriteLn, Read, ReadLn ®â­®á¨â¥«ì­® áâ ­¤ àâ­®© ª®­á®«¨ ¢¢®¤ /¢ë¢®¤ .
}
program Example; program Example;
{ ‚ᥠä㭪樨 ¨¬¥î騥 ¢ ᢮¥¬ ¨¬¥­¨ ¯à¥ä¨ªá 'kos_' ïîâáï ¯« âä®à¬®§ ¢¨á¨¬ë¬¨ { ‚ᥠä㭪樨 ¨¬¥î騥 ¢ ᢮¥¬ ¨¬¥­¨ ¯à¥ä¨ªá 'kos_' ïîâáï ¯« âä®à¬®§ ¢¨á¨¬ë¬¨
¨ ॠ«¨§®¢ ­ë ⮫쪮 ¯®¤ KolibriOS. ˆå ¨á¯®«ì§®¢ ­¨¥ ¢ «î¡ëå ¯à®£à ¬¬­ëå ¨ ॠ«¨§®¢ ­ë ⮫쪮 ¤«ï KolibriOS. ˆå ¨á¯®«ì§®¢ ­¨¥ ¢ «î¡ëå ¯à®£à ¬¬­ëå
¯à¨«®¦¥­¨ïå ª â¥£®à¨ç¥áª¨ ­¥ ४®¬¥­¤®¢ ­®, ¢ë­®á¨â¥ ¢á¥ ¬¥â®¤ë, ¨á¯®«ì§ãî騥 ¯à¨«®¦¥­¨ïå ª â¥£®à¨ç¥áª¨ ­¥ ४®¬¥­¤®¢ ­®, ¢ë­®á¨â¥ ¢á¥ ¬¥â®¤ë, ¨á¯®«ì§ãî騥
í⨠ä㭪樨, ¢ ®â¤¥«ì­ë¥ ¬®¤ã«¨ (¨ ¨á¯®«ì§ã©â¥ ­¥®¡å®¤¨¬ë¥  ¡áâࠪ樨). í⨠ä㭪樨, ¢ ®â¤¥«ì­ë¥ ¬®¤ã«¨ (¨ ¨á¯®«ì§ã©â¥ ­¥®¡å®¤¨¬ë¥  ¡áâࠪ樨). }
}
procedure DoPaint; procedure DoPaint;
{ ‚뢮¤ ᮤ¥à¦¨¬®£® ®ª­  ¯à¨«®¦¥­¨ï } { ‚뢮¤ ᮤ¥à¦¨¬®£® ®ª­  ¯à¨«®¦¥­¨ï }
begin begin
kos_begindraw(); kos_begindraw();
{®¯à¥¤¥«¥­¨¥ ¯ à ¬¥â஢ ®ª­ }
{ ®¯à¥¤¥«¥­¨¥ ¯ à ¬¥â஢ ®ª­  }
kos_definewindow(200, 200, 200, 50, $23AABBCC); kos_definewindow(200, 200, 200, 50, $23AABBCC);
{kos_definewindow ­¥ ¨¬¥¥â ¯ à ¬¥âà  ¤«ï ¢ë¢®¤  § £®«®¢ª ,
¤¥« ¥¬ íâ® ®â¤¥«ì­®© ä㭪樥© kos_setcaption} { kos_definewindow ­¥ ¨¬¥¥â ¯ à ¬¥âà  ¤«ï ¢ë¢®¤  § £®«®¢ª ,
{®â®¡à ¦¥­¨¥ § £®«®¢ª  ®ª­ } ¤¥« ¥¬ íâ® ®â¤¥«ì­®© ä㭪樥© kos_setcaption }
{ ®â®¡à ¦¥­¨¥ § £®«®¢ª  ®ª­  }
kos_setcaption('<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ'); kos_setcaption('<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ');
{¢ë¢®¤ á®®¡é¥­¨ï}
{ ¢ë¢®¤ á®®¡é¥­¨ï }
kos_drawtext(3, 8, '<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...'); kos_drawtext(3, 8, '<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...');
kos_enddraw(); kos_enddraw();
end; end;
procedure DoKey; procedure DoKey;
{ Ž¡à ¡®âª  ᮡëâ¨ï ­ ¦ â¨ï ª« ¢¨è¨ } { Ž¡à ¡®âª  ᮡëâ¨ï ­ ¦ â¨ï ª« ¢¨è¨ }
var var
@ -42,11 +41,13 @@ var
Notes: array[0..3] of Byte; Notes: array[0..3] of Byte;
begin begin
Key := kos_getkey(); Key := kos_getkey();
{­ áâà ¨¢ ¥¬ ¡ãä¥à ¤«ï ­®â}
{ ­ áâà ¨¢ ¥¬ ¡ãä¥à ¤«ï ­®â }
Notes[0] := $90; Notes[0] := $90;
Notes[1] := Key shr 8; Notes[1] := Key shr 8;
Notes[2] := $00; Notes[2] := $00;
{¢®á¯à®¨§¢®¤¨¬}
{ ¢®á¯à®¨§¢®¤¨¬ }
kos_speaker(@Notes); kos_speaker(@Notes);
end; end;
@ -56,9 +57,10 @@ function DoButton: Boolean;
var var
Button: DWord; Button: DWord;
begin begin
{¯®«ãç¨âì ª®¤ ­ ¦ â®© ª«¨¢¨è¨} { ¯®«ãç¨âì ª®¤ ­ ¦ â®© ª«¨¢¨è¨ }
Button := kos_getbutton(); Button := kos_getbutton();
{¥á«¨ [x], â® ¢¥à­ãâì «®¦ì,   §­ ç¨â á¯à®¢®æ¨à®¢ âì § ªàë⨥ ¯à¨«®¦¥­¨ï}
{ ¥á«¨ [x], â® ¢¥à­ãâì «®¦ì,   §­ ç¨â á¯à®¢®æ¨à®¢ âì § ªàë⨥ ¯à¨«®¦¥­¨ï }
Result := Button <> 1; Result := Button <> 1;
end; end;
@ -67,35 +69,30 @@ function ProcessMessage: Boolean;
{ Ž¦¨¤ ­¨¥ ¨ ®¡à ¡®âª  ᮡë⨩. { Ž¦¨¤ ­¨¥ ¨ ®¡à ¡®âª  ᮡë⨩.
@return: ‚®§¢à é ¥â False, ¥á«¨ ¡ë«® ᮡë⨥ ª § ¢¥à襭¨î ¯à¨«®¦¥­¨ï. @return: ‚®§¢à é ¥â False, ¥á«¨ ¡ë«® ᮡë⨥ ª § ¢¥à襭¨î ¯à¨«®¦¥­¨ï.
@rtype: True ¨«¨ False } @rtype : True ¨«¨ False }
var var
Event: DWord; Event: DWord;
begin begin
Result := True; Result := True;
{®¦¨¤ ¥¬ ᮡëâ¨ï ®â á¨á⥬ë}
{ ®¦¨¤ ¥¬ ᮡëâ¨ï ®â á¨á⥬ë }
Event := kos_getevent(); Event := kos_getevent();
case Event of case Event of
SE_PAINT : DoPaint; {¯¥à¥à¨á®¢ª  ®ª­ } SE_PAINT : DoPaint; { ¯¥à¥à¨á®¢ª  ®ª­  }
SE_KEYBOARD: DoKey; {ᮡë⨥ ®â ª« ¢¨ âãàë} SE_KEYBOARD: DoKey; { ᮡë⨥ ®â ª« ¢¨ âãàë }
SE_BUTTON : Result := DoButton; {ᮡ먥 ®â ª­®¯ª¨, ¬®¦¥â ®¯à¥¤¥«¨âì SE_BUTTON : Result := DoButton; { ᮡë⨥ ®â ª­®¯ª¨, ¬®¦¥â ®¯à¥¤¥«¨âì
§ ¢¥à襭¨¥ ¯à¨«®¦¥­¨ï, ¥á«¨ ¢¥à­¥â False} § ¢¥à襭¨¥ ¯à¨«®¦¥­¨ï, ¥á«¨ ¢¥à­¥â False }
end; end;
end; end;
procedure MainLoop;
{ ƒ« ¢­ë© 横« ¯à¨«®¦¥­¨ï } { ƒ« ¢­ë© 横« ¯à¨«®¦¥­¨ï }
var var
ThreadSlot: TThreadSlot; ThreadSlot: TThreadSlot;
begin begin
{­ áâà ¨¢ ¥¬ ᮡëâ¨ï, ª®â®àë¥ ¬ë £®â®¢ë ®¡à ¡ â뢠âì} { ­ áâà ¨¢ ¥¬ ᮡëâ¨ï, ª®â®àë¥ ¬ë £®â®¢ë ®¡à ¡ â뢠âì }
kos_maskevents(ME_PAINT or ME_KEYBOARD or ME_BUTTON); kos_maskevents(ME_PAINT or ME_KEYBOARD or ME_BUTTON);
{®¡à ¡®âª  ᮡë⨩}
{ ®¡à ¡®âª  ᮡë⨩ }
while ProcessMessage do; while ProcessMessage do;
end;
begin
WriteLn('Look for a new window, I''m just a konsole ;-)');
MainLoop;
end. end.

View File

@ -0,0 +1,67 @@
#
# Makefile.fpc for Free Pascal KolibriOS RTL
#
[package]
main=rtl
[target]
loaders=$(LOADERS)
units=system objpas buildrtl
#implicitunits=sysinitpas sysinitcyg sysinitgprof \
# ctypes strings \
# lineinfo lnfodwrf heaptrc matrix \
# windows winsock winsock2 initc cmem dynlibs signals \
# dos crt objects messages \
# rtlconsts sysconst sysutils math types \
# strutils dateutils varutils variants typinfo fgl classes \
# convutils stdconvs cpu mmx charset ucomplex getopts \
# winevent sockets printer \
# video mouse keyboard fmtbcd \
# winsysut sharemem
#rsts=math varutils typinfo variants classes dateutils sysconst
[require]
nortl=y
[install]
fpcpackage=y
[default]
target=win32
cpu=i386
[compiler]
unittargetdir=../units/rtl
includedir=$(INC) $(PROCINC)
sourcedir=$(INC) $(PROCINC)
[prerules]
RTL=$(FPCDIR)/rtl
INC=$(RTL)/inc
PROCINC=$(RTL)/$(CPU_TARGET)
OBJPASDIR=$(RTL)/objpas
[rules]
.NOTPARALLEL:
SYSTEMPPU=$(addsuffix $(PPUEXT),system)
include $(INC)/makefile.inc
SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
include $(PROCINC)/makefile.cpu
SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
# Unit specific rules
system$(PPUEXT): system.pp $(SYSDEPS)
$(COMPILER) -Us -Sg system.pp
objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc system$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
buildrtl$(PPUEXT): buildrtl.pp system$(PPUEXT) objpas$(PPUEXT)
$(COMPILER) -Fi$(OBJPASDIR)/sysutils -Fi$(OBJPASDIR)/classes -Fu$(PROCINC) -I$(OBJPASDIR) -I$(INC) -Fu$(INC) -Fu$(OBJPASDIR) buildrtl

View File

@ -1,21 +1,3 @@
@echo off @echo off
fpcmake -Twin32
set FPRTL={FreePascal RTL source code, example c:\fp\src\rtl} make
set INCS=-Fi%FPRTL%\inc;%FPRTL%\i386;%FPRTL%\objpas;%FPRTL%\objpas\sysutils;%FPRTL%\objpas\classes
set UNTS=-Fu%FPRTL%\inc;%FPRTL%\i386;%FPRTL%\objpas
set BUILDPATH=..\units
set FPCARGS=-n -Twin32 -Sge5 -O3pPENTIUM3 -CfSSE -di386 -FU%BUILDPATH% %INCS% %UNTS%
fpc system.pp -Us %FPCARGS%
if errorlevel 1 goto error
fpc %FPRTL%\objpas\objpas.pp %FPCARGS%
if errorlevel 1 goto error
fpc buildrtl.pp %FPCARGS%
if errorlevel 0 goto end
:error
echo An error occured while building RTL
:end

View File

@ -0,0 +1,3 @@
#!/bin/sh
fpcmake -Twin32
make

View File

@ -152,5 +152,8 @@ begin
end; end;
if InOutRes <> 0 then if InOutRes <> 0 then
begin
FreeMem(KosFile); FreeMem(KosFile);
FileRec(f).Handle := DWord(-1);
end;
end; end;

View File

@ -1,4 +1,4 @@
{cp866} {utf8}
unit System; unit System;
{$i _defines.inc} {$i _defines.inc}
@ -56,16 +56,16 @@ begin
begin begin
while Args^ <> #0 do while Args^ <> #0 do
begin begin
{<EFBFBD>யãáâ¨âì «¨¤¨àãî騥 ¯à®¡¥«ë} {Пропустить лидирующие пробелы}
while Args^ in [#1..#32] do Inc(Args); while Args^ in [#1..#32] do Inc(Args);
if Args^ = #0 then Break; if Args^ = #0 then Break;
{‡ ¯®¬­¨âì 㪠§ â¥«ì ­  ¯ à ¬¥âà} {Запомнить указатель на параметр}
SetLength(Ptrs, Argc); SetLength(Ptrs, Argc);
Ptrs[Argc - 1] := Args; Ptrs[Argc - 1] := Args;
Inc(Argc); Inc(Argc);
{<EFBFBD>யãáâ¨âì ⥪ã騩 ¯ à ¬¥âà} {Пропустить текущий параметр}
InQuotes := False; InQuotes := False;
while (Args^ <> #0) and (not (Args^ in [#1..#32]) or InQuotes) do while (Args^ <> #0) and (not (Args^ in [#1..#32]) or InQuotes) do
begin begin
@ -73,7 +73,7 @@ begin
Inc(Args); Inc(Args);
end; end;
{“áâ ­®¢¨âì ®ª®­ç ­¨¥ ¯ à ¬¥âà } {Установить окончание параметра}
if Args^ in [#1..#32] then if Args^ in [#1..#32] then
begin begin
Args^ := #0; Args^ := #0;
@ -81,12 +81,12 @@ begin
end; end;
end; end;
end; end;
Argv := GetMem(Argc * SizeOf(PChar)); {XXX: ¯ ¬ïâì ­¥ ®á¢®¡®¦¤ ¥âáï} Argv := GetMem(Argc * SizeOf(PChar)); {XXX: память не освобождается}
Argv[0] := PKosHeader(0)^.path; Argv[0] := PKosHeader(0)^.path;
for I := 1 to Argc - 1 do for I := 1 to Argc - 1 do
begin begin
Argv[I] := Ptrs[I - 1]; Argv[I] := Ptrs[I - 1];
{ˆáª«îç¨âì ª ¢ë窨 ¨§ áâப¨} {Исключить кавычки из строки}
Args := Argv[I]; Args := Argv[I];
L := 0; L := 0;
while Args^ <> #0 do begin Inc(Args); Inc(L); end; while Args^ <> #0 do begin Inc(Args); Inc(L); end;
@ -118,7 +118,7 @@ end;
procedure Randomize; procedure Randomize;
begin begin
randseed := 0; {GetTickCount()} randseed := kos_timecounter();
end; end;
const const
@ -136,7 +136,6 @@ begin
end; end;
{$i kos_stdio.inc} {$i kos_stdio.inc}
{-$i kos_term.inc}
procedure SysInitStdIO; procedure SysInitStdIO;
begin begin
@ -158,15 +157,15 @@ begin
begin begin
if ExitCode <> 0 then if ExitCode <> 0 then
begin begin
{XXX: ®¡ï§ â¥«ì­®¥ ãá«®¢¨¥ ­  ®¤­®¯®â®ç­ë© Konsole} {XXX: обязательное условие на однопоточный Konsole}
Write(StdErr, '[Error #', ExitCode,', press any key]'); Write(StdErr, '[Error #', ExitCode,', press any key]');
{®¦¨¤ âì ­ ¦ â¨ï ª« ¢¨è¨} {ожидать нажатия клавиши}
Konsole.KeyPressed; Konsole.KeyPressed;
while Konsole.KeyPressed = 0 do kos_delay(2); while Konsole.KeyPressed = 0 do kos_delay(2);
{TODO: ¨á¯à ¢¨âì ª®áïª ¯à¨ ¯¥à¥à¨á®¢ª¥ Konsole} {TODO: исправить косяк при перерисовке Konsole}
{íâ® ­¥¢®§¬®¦­®, â ª ª ª ªãç  ®á¢®¡®¦¤ ¥âáï ¥é¥ ¤® ¢ë§®¢  í⮩ ¯à®æ¥¤ãàë} {это невозможно, так как куча освобождается еще до вызова этой процедуры}
{¬®¦­® ­ ¯¨á âì ᢮© ¤¨á¯¥âç¥à ¯ ¬ïâ¨, ­® íâ® á«®¦­®} {можно написать свой диспетчер памяти, но это сложно}
{  ¥á«¨ ¢ Konsole ¨á¯®«ì§®¢ âì ¢ë¤¥«¥­¨¥ ¯ ¬ï⨠­ ¯àï¬ãî ç¥à¥§ KosAPI?!} {а если в Konsole использовать выделение памяти напрямую через KosAPI?!}
end; end;
Close(StdErr); Close(StdErr);
Close(StdOut); Close(StdOut);

View File

@ -1,12 +1,13 @@
{utf8}
unit sysutils; unit sysutils;
{$i _defines.inc} {$i _defines.inc}
{$mode objfpc}
{$h+}
interface interface
{$mode objfpc}
{ force ansistrings } { force ansistrings }
{$h+}
{$DEFINE HAS_SLEEP} {$DEFINE HAS_SLEEP}
{-$DEFINE HAS_OSERROR} {-$DEFINE HAS_OSERROR}
@ -150,7 +151,7 @@ begin
fsFromCurrent: Position := FilePos(FileRecordByHandle(Handle)^.F) + FOffset; fsFromCurrent: Position := FilePos(FileRecordByHandle(Handle)^.F) + FOffset;
fsFromEnd: Position := FileSize(FileRecordByHandle(Handle)^.F) + FOffset; fsFromEnd: Position := FileSize(FileRecordByHandle(Handle)^.F) + FOffset;
end; end;
{TODO: 能恥丞<EFBFBD> 嵼栽╞皸潳剁 [0..filesize]} {TODO: проверка соответствия [0..filesize]}
Seek(FileRecordByHandle(Handle)^.F, Position); Seek(FileRecordByHandle(Handle)^.F, Position);
Result := Position; Result := Position;
end; end;
@ -175,15 +176,16 @@ function FileExists(const FileName: String): Boolean;
var var
F: File; F: File;
begin begin
{$i-}
Assign(F, FileName); Assign(F, FileName);
try Reset(F);
Reset(F); if IOResult = 0 then
FileSize(F); begin
Result := True; Result := True;
except Close(F);
end else
Result := False; Result := False;
end; {$i+}
Close(F);
end; end;
function DirectoryExists(const Directory: String): Boolean; function DirectoryExists(const Directory: String): Boolean;

View File

@ -0,0 +1,5 @@
@echo off
fpc -Twin32 exe2kos.pp
del *.o
del *.ppu
move exe2kos.exe ..\..\bin

View File

@ -0,0 +1,5 @@
#!/bin/sh
fpc -Tlinux exe2kos.pp &&
rm *.o &&
rm *.ppu &&
mv exe2kos ../../bin