mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 01:08:35 +02:00
* Patch from Karl-Michael Schindler to prepend TMP to temp filename../inc/iso7185.pp
git-svn-id: trunk@34478 -
This commit is contained in:
parent
abc33b81cc
commit
4fa2ec7740
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9062,6 +9062,7 @@ rtl/java/objpash.inc svneol=native#text/plain
|
||||
rtl/java/rtl.cfg svneol=native#text/plain
|
||||
rtl/java/rtldefs.inc svneol=native#text/plain
|
||||
rtl/java/rtti.inc svneol=native#text/plain
|
||||
rtl/java/sysfile.inc svneol=native#text/plain
|
||||
rtl/java/sysos.inc svneol=native#text/plain
|
||||
rtl/java/sysosh.inc svneol=native#text/plain
|
||||
rtl/java/sysres.inc svneol=native#text/plain
|
||||
|
@ -19322,7 +19322,7 @@
|
||||
constructor create(); overload;
|
||||
function getStatus(): AOAsyncTask.InnerStatus; overload; virtual; final;
|
||||
strict protected
|
||||
function doInBackground(para1: Arr1JLObject): JLObject; overload; virtual; abstract;
|
||||
// function doInBackground(para1: Arr1JLObject): JLObject; overload; virtual; abstract;
|
||||
function doInBackground(const para1: array of JLObject): JLObject; overload; virtual; abstract;
|
||||
procedure onPreExecute(); overload; virtual;
|
||||
procedure onPostExecute(para1: JLObject); overload; virtual;
|
||||
|
@ -47,6 +47,52 @@ unit iso7185;
|
||||
|
||||
implementation
|
||||
|
||||
function getTempDir: string;
|
||||
var
|
||||
key: string;
|
||||
value: string;
|
||||
i_env, i_key, i_value: integer;
|
||||
pd : char; // Pathdelim not available ?
|
||||
begin
|
||||
{$IFDEF HASUNIX}
|
||||
value := '/tmp/'; (** default for UNIX **)
|
||||
pd:='/';
|
||||
{$ELSE}
|
||||
value := '';
|
||||
pd:='\';
|
||||
{$ENDIF}
|
||||
while (envp <> NIL) and assigned(envp^) do
|
||||
begin
|
||||
i_env := 0;
|
||||
i_key := 1;
|
||||
while not (envp^[i_env] in ['=', #0]) do
|
||||
begin
|
||||
key[i_key] := envp^[i_env];
|
||||
inc(i_env);
|
||||
inc(i_key);
|
||||
end;
|
||||
setlength(key, i_key - 1);
|
||||
if (key = 'TEMP') or (key = 'TMP') or (key = 'TMPDIR') then
|
||||
begin
|
||||
inc(i_env); (** skip '=' **)
|
||||
i_value := 1;
|
||||
while (envp^[i_env] <> #0) do
|
||||
begin
|
||||
value[i_value] := envp^[i_env];
|
||||
inc(i_env);
|
||||
inc(i_value);
|
||||
end;
|
||||
setlength(value, i_value - 1);
|
||||
end;
|
||||
inc(envp);
|
||||
end;
|
||||
i_value:=length(value);
|
||||
if (i_value>0) and (value[i_value]<>pd) then
|
||||
value:=value+pd;
|
||||
getTempDir := value;
|
||||
end;
|
||||
|
||||
|
||||
{$i-}
|
||||
procedure DoAssign(var t : Text);
|
||||
{$ifndef FPC_HAS_FEATURE_RANDOM}
|
||||
@ -55,9 +101,9 @@ unit iso7185;
|
||||
{$endif FPC_HAS_FEATURE_RANDOM}
|
||||
begin
|
||||
{$ifdef FPC_HAS_FEATURE_RANDOM}
|
||||
Assign(t,'fpc_'+HexStr(random(1000000000),8)+'.tmp');
|
||||
Assign(t,getTempDir+'fpc_'+HexStr(random(1000000000),8)+'.tmp');
|
||||
{$else FPC_HAS_FEATURE_RANDOM}
|
||||
Assign(t,'fpc_'+HexStr(NextIndex,4)+'.tmp');
|
||||
Assign(t,getTempDir+'fpc_'+HexStr(NextIndex,4)+'.tmp');
|
||||
Inc(NextIndex);
|
||||
{$endif FPC_HAS_FEATURE_RANDOM}
|
||||
end;
|
||||
|
@ -77,7 +77,13 @@ End;
|
||||
Procedure InitText(Var t : Text);
|
||||
|
||||
begin
|
||||
{$IFDEF CPUJVM}
|
||||
TextRec(t).bufend:=0;
|
||||
TextRec(t).bufpos:=0;
|
||||
TextRec(t).Handle:=Nil;
|
||||
{$ELSE}
|
||||
FillChar(t,SizeOf(TextRec),0);
|
||||
{$ENDIF}
|
||||
{ only set things that are not zero }
|
||||
TextRec(t).Handle:=UnusedHandle;
|
||||
TextRec(t).mode:=fmClosed;
|
||||
@ -293,7 +299,11 @@ Begin
|
||||
If InOutRes=0 then
|
||||
TextRec(t).Name:=fs
|
||||
{$else FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
|
||||
{$IFDEF CPUJVM}
|
||||
Do_Rename(PFileTextRecChar(@TextRec(t).Name),S,false,false);
|
||||
{$ELSE}
|
||||
Do_Rename(PFileTextRecChar(@TextRec(t).Name),PUnicodeChar(S),false,false);
|
||||
{$ENDIF}
|
||||
If InOutRes=0 then
|
||||
{$ifdef FPC_ANSI_TEXTTextRec}
|
||||
TextRec(t).Name:=ToSingleByteFileSystemEncodedFileName(s);
|
||||
@ -314,7 +324,11 @@ var
|
||||
pdst: PAnsiChar;
|
||||
{$else FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
|
||||
fs: UnicodeString;
|
||||
{$IFDEF CPUJVM}
|
||||
pdst: Unicodestring;
|
||||
{$else}
|
||||
pdst: PUnicodeChar;
|
||||
{$ENDIF}
|
||||
{$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
|
||||
dstchangeable: boolean;
|
||||
Begin
|
||||
@ -339,8 +353,12 @@ Begin
|
||||
{$else FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
|
||||
{ it's slightly faster to convert the rawbytestring here to unicodestring
|
||||
than doing it in do_rename, because here we still know the length }
|
||||
{$IFNDEF CPUJVM}
|
||||
fs:=unicodestring(s);
|
||||
pdst:=PUnicodeChar(fs);
|
||||
{$ELSE}
|
||||
pdst:=unicodestring(s);
|
||||
{$ENDIF CPUJVM}
|
||||
dstchangeable:=true;
|
||||
{$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
|
||||
Do_Rename(PFileTextRecChar(@TextRec(t).Name),pdst,false,dstchangeable);
|
||||
|
@ -29,7 +29,7 @@ const
|
||||
{$endif CPUAVR}
|
||||
type
|
||||
TLineEndStr = string [3];
|
||||
TextBuf = array[0..TextRecBufSize-1] of ansichar;
|
||||
TextBuf = array[0..TextRecBufSize-1] of {$IFDEF CPUJVM}UnicodeChar {$ELSE}ansichar{$ENDIF};
|
||||
TTextBuf = TextBuf;
|
||||
|
||||
{ using packed makes the compiler to generate ugly code on some CPUs, further
|
||||
|
@ -2751,3 +2751,423 @@
|
||||
function entrySet(): JUSet; overload; virtual;
|
||||
end;
|
||||
|
||||
JNURI = class sealed external 'java.net' name 'URI' (JLObject, JLComparable, JISerializable)
|
||||
public
|
||||
type
|
||||
InnerParser = class;
|
||||
Arr1InnerParser = array of InnerParser;
|
||||
Arr2InnerParser = array of Arr1InnerParser;
|
||||
Arr3InnerParser = array of Arr2InnerParser;
|
||||
InnerParser = class external 'java.net' name 'Parser'
|
||||
end;
|
||||
|
||||
public
|
||||
constructor create(para1: JLString); overload; // throws java.net.URISyntaxException
|
||||
constructor create(para1: JLString; para2: JLString; para3: JLString; para4: jint; para5: JLString; para6: JLString; para7: JLString); overload; // throws java.net.URISyntaxException
|
||||
constructor create(para1: JLString; para2: JLString; para3: JLString; para4: JLString; para5: JLString); overload; // throws java.net.URISyntaxException
|
||||
constructor create(para1: JLString; para2: JLString; para3: JLString; para4: JLString); overload; // throws java.net.URISyntaxException
|
||||
constructor create(para1: JLString; para2: JLString; para3: JLString); overload; // throws java.net.URISyntaxException
|
||||
class function create_(para1: JLString): JNURI; static; external name 'create'; overload;
|
||||
function parseServerAuthority(): JNURI; overload; virtual; // throws java.net.URISyntaxException
|
||||
function normalize(): JNURI; overload; virtual;
|
||||
function resolve(para1: JNURI): JNURI; overload; virtual;
|
||||
function resolve(para1: JLString): JNURI; overload; virtual;
|
||||
function relativize(para1: JNURI): JNURI; overload; virtual;
|
||||
function toURL(): JNURL; overload; virtual; // throws java.net.MalformedURLException
|
||||
function getScheme(): JLString; overload; virtual;
|
||||
function isAbsolute(): jboolean; overload; virtual;
|
||||
function isOpaque(): jboolean; overload; virtual;
|
||||
function getRawSchemeSpecificPart(): JLString; overload; virtual;
|
||||
function getSchemeSpecificPart(): JLString; overload; virtual;
|
||||
function getRawAuthority(): JLString; overload; virtual;
|
||||
function getAuthority(): JLString; overload; virtual;
|
||||
function getRawUserInfo(): JLString; overload; virtual;
|
||||
function getUserInfo(): JLString; overload; virtual;
|
||||
function getHost(): JLString; overload; virtual;
|
||||
function getPort(): jint; overload; virtual;
|
||||
function getRawPath(): JLString; overload; virtual;
|
||||
function getPath(): JLString; overload; virtual;
|
||||
function getRawQuery(): JLString; overload; virtual;
|
||||
function getQuery(): JLString; overload; virtual;
|
||||
function getRawFragment(): JLString; overload; virtual;
|
||||
function getFragment(): JLString; overload; virtual;
|
||||
function equals(para1: JLObject): jboolean; overload; virtual;
|
||||
function hashCode(): jint; overload; virtual;
|
||||
function compareTo(para1: JNURI): jint; overload; virtual;
|
||||
function toString(): JLString; overload; virtual;
|
||||
function toASCIIString(): JLString; overload; virtual;
|
||||
function compareTo(para1: JLObject): jint; overload; virtual;
|
||||
end;
|
||||
|
||||
JIFile = class external 'java.io' name 'File' (JLObject, JISerializable, JLComparable)
|
||||
public
|
||||
type
|
||||
InnerLazyInitialization = class;
|
||||
Arr1InnerLazyInitialization = array of InnerLazyInitialization;
|
||||
Arr2InnerLazyInitialization = array of Arr1InnerLazyInitialization;
|
||||
Arr3InnerLazyInitialization = array of Arr2InnerLazyInitialization;
|
||||
InnerLazyInitialization = class external 'java.io' name 'LazyInitialization'
|
||||
end;
|
||||
|
||||
public
|
||||
final class var
|
||||
fseparatorChar: jchar; external name 'separatorChar';
|
||||
fseparator: JLString; external name 'separator';
|
||||
fpathSeparatorChar: jchar; external name 'pathSeparatorChar';
|
||||
fpathSeparator: JLString; external name 'pathSeparator';
|
||||
public
|
||||
constructor create(para1: JLString); overload;
|
||||
constructor create(para1: JLString; para2: JLString); overload;
|
||||
constructor create(para1: JIFile; para2: JLString); overload;
|
||||
constructor create(para1: JNURI); overload;
|
||||
function getName(): JLString; overload; virtual;
|
||||
function getParent(): JLString; overload; virtual;
|
||||
function getParentFile(): JIFile; overload; virtual;
|
||||
function getPath(): JLString; overload; virtual;
|
||||
function isAbsolute(): jboolean; overload; virtual;
|
||||
function getAbsolutePath(): JLString; overload; virtual;
|
||||
function getAbsoluteFile(): JIFile; overload; virtual;
|
||||
function getCanonicalPath(): JLString; overload; virtual; // throws java.io.IOException
|
||||
function getCanonicalFile(): JIFile; overload; virtual; // throws java.io.IOException
|
||||
function toURL(): JNURL; overload; virtual; // throws java.net.MalformedURLException
|
||||
function toURI(): JNURI; overload; virtual;
|
||||
function canRead(): jboolean; overload; virtual;
|
||||
function canWrite(): jboolean; overload; virtual;
|
||||
function exists(): jboolean; overload; virtual;
|
||||
function isDirectory(): jboolean; overload; virtual;
|
||||
function isFile(): jboolean; overload; virtual;
|
||||
function isHidden(): jboolean; overload; virtual;
|
||||
function lastModified(): jlong; overload; virtual;
|
||||
function length(): jlong; overload; virtual;
|
||||
function createNewFile(): jboolean; overload; virtual; // throws java.io.IOException
|
||||
function delete(): jboolean; overload; virtual;
|
||||
procedure deleteOnExit(); overload; virtual;
|
||||
function list(): Arr1JLString; overload; virtual;
|
||||
function list(para1: JIFilenameFilter): Arr1JLString; overload; virtual;
|
||||
function listFiles(): Arr1JIFile; overload; virtual;
|
||||
function listFiles(para1: JIFilenameFilter): Arr1JIFile; overload; virtual;
|
||||
function listFiles(para1: JIFileFilter): Arr1JIFile; overload; virtual;
|
||||
function mkdir(): jboolean; overload; virtual;
|
||||
function mkdirs(): jboolean; overload; virtual;
|
||||
function renameTo(para1: JIFile): jboolean; overload; virtual;
|
||||
function setLastModified(para1: jlong): jboolean; overload; virtual;
|
||||
function setReadOnly(): jboolean; overload; virtual;
|
||||
function setWritable(para1: jboolean; para2: jboolean): jboolean; overload; virtual;
|
||||
function setWritable(para1: jboolean): jboolean; overload; virtual;
|
||||
function setReadable(para1: jboolean; para2: jboolean): jboolean; overload; virtual;
|
||||
function setReadable(para1: jboolean): jboolean; overload; virtual;
|
||||
function setExecutable(para1: jboolean; para2: jboolean): jboolean; overload; virtual;
|
||||
function setExecutable(para1: jboolean): jboolean; overload; virtual;
|
||||
function canExecute(): jboolean; overload; virtual;
|
||||
class function listRoots(): Arr1JIFile; static; overload;
|
||||
function getTotalSpace(): jlong; overload; virtual;
|
||||
function getFreeSpace(): jlong; overload; virtual;
|
||||
function getUsableSpace(): jlong; overload; virtual;
|
||||
class function createTempFile(para1: JLString; para2: JLString; para3: JIFile): JIFile; static; overload; // throws java.io.IOException
|
||||
class function createTempFile(para1: JLString; para2: JLString): JIFile; static; overload; // throws java.io.IOException
|
||||
function compareTo(para1: JIFile): jint; overload; virtual;
|
||||
function equals(para1: JLObject): jboolean; overload; virtual;
|
||||
function hashCode(): jint; overload; virtual;
|
||||
function toString(): JLString; overload; virtual;
|
||||
function compareTo(para1: JLObject): jint; overload; virtual;
|
||||
end;
|
||||
|
||||
JNCScatteringByteChannel = interface external 'java.nio.channels' name 'ScatteringByteChannel' (JNCReadableByteChannel)
|
||||
function read(para1: Arr1JNByteBuffer; para2: jint; para3: jint): jlong; overload; // throws java.io.IOException
|
||||
function read(var para1: array of JNByteBuffer; para2: jint; para3: jint): jlong; overload; // throws java.io.IOException
|
||||
function read(para1: Arr1JNByteBuffer): jlong; overload; // throws java.io.IOException
|
||||
function read(var para1: array of JNByteBuffer): jlong; overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JNCByteChannel = interface external 'java.nio.channels' name 'ByteChannel' (JNCReadableByteChannel, JNCWritableByteChannel)
|
||||
end;
|
||||
|
||||
JNCGatheringByteChannel = interface external 'java.nio.channels' name 'GatheringByteChannel' (JNCWritableByteChannel)
|
||||
function write(para1: Arr1JNByteBuffer; para2: jint; para3: jint): jlong; overload; // throws java.io.IOException
|
||||
function write(var para1: array of JNByteBuffer; para2: jint; para3: jint): jlong; overload; // throws java.io.IOException
|
||||
function write(para1: Arr1JNByteBuffer): jlong; overload; // throws java.io.IOException
|
||||
function write(var para1: array of JNByteBuffer): jlong; overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JNMappedByteBuffer = class abstract external 'java.nio' name 'MappedByteBuffer' (JNByteBuffer)
|
||||
public
|
||||
function isLoaded(): jboolean; overload; virtual; final;
|
||||
function load(): JNMappedByteBuffer; overload; virtual; final;
|
||||
function force(): JNMappedByteBuffer; overload; virtual; final;
|
||||
end;
|
||||
|
||||
JNCFileLock = class abstract external 'java.nio.channels' name 'FileLock' (JLObject)
|
||||
strict protected
|
||||
constructor create(para1: JNCFileChannel; para2: jlong; para3: jlong; para4: jboolean); overload;
|
||||
public
|
||||
function channel(): JNCFileChannel; overload; virtual; final;
|
||||
function position(): jlong; overload; virtual; final;
|
||||
function size(): jlong; overload; virtual; final;
|
||||
function isShared(): jboolean; overload; virtual; final;
|
||||
function overlaps(para1: jlong; para2: jlong): jboolean; overload; virtual; final;
|
||||
function isValid(): jboolean; overload; virtual; abstract;
|
||||
procedure release(); overload; virtual; abstract; // throws java.io.IOException
|
||||
function toString(): JLString; overload; virtual; final;
|
||||
end;
|
||||
|
||||
JNCSAbstractInterruptibleChannel = class abstract external 'java.nio.channels.spi' name 'AbstractInterruptibleChannel' (JLObject, JNCChannel, JNCInterruptibleChannel)
|
||||
strict protected
|
||||
constructor create(); overload;
|
||||
public
|
||||
procedure close(); overload; virtual; final; // throws java.io.IOException
|
||||
strict protected
|
||||
procedure implCloseChannel(); overload; virtual; abstract; // throws java.io.IOException
|
||||
public
|
||||
function isOpen(): jboolean; overload; virtual; final;
|
||||
strict protected
|
||||
procedure &begin(); overload; virtual; final;
|
||||
procedure &end(para1: jboolean); overload; virtual; final; // throws java.nio.channels.AsynchronousCloseException
|
||||
end;
|
||||
|
||||
JNCFileChannel = class abstract external 'java.nio.channels' name 'FileChannel' (JNCSAbstractInterruptibleChannel, JNCByteChannel, JNCGatheringByteChannel, JNCScatteringByteChannel)
|
||||
public
|
||||
type
|
||||
InnerMapMode = class;
|
||||
Arr1InnerMapMode = array of InnerMapMode;
|
||||
Arr2InnerMapMode = array of Arr1InnerMapMode;
|
||||
Arr3InnerMapMode = array of Arr2InnerMapMode;
|
||||
InnerMapMode = class external 'java.nio.channels' name 'MapMode' (JLObject)
|
||||
public
|
||||
final class var
|
||||
fREAD_ONLY: JNCFileChannel.InnerMapMode; external name 'READ_ONLY';
|
||||
fREAD_WRITE: JNCFileChannel.InnerMapMode; external name 'READ_WRITE';
|
||||
fPRIVATE: JNCFileChannel.InnerMapMode; external name 'PRIVATE';
|
||||
public
|
||||
function toString(): JLString; overload; virtual;
|
||||
end;
|
||||
|
||||
strict protected
|
||||
constructor create(); overload;
|
||||
public
|
||||
function read(para1: JNByteBuffer): jint; overload; virtual; abstract; // throws java.io.IOException
|
||||
function read(para1: Arr1JNByteBuffer; para2: jint; para3: jint): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function read(var para1: array of JNByteBuffer; para2: jint; para3: jint): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function read(para1: Arr1JNByteBuffer): jlong; overload; virtual; final; // throws java.io.IOException
|
||||
function read(var para1: array of JNByteBuffer): jlong; overload; virtual; final; // throws java.io.IOException
|
||||
function write(para1: JNByteBuffer): jint; overload; virtual; abstract; // throws java.io.IOException
|
||||
function write(para1: Arr1JNByteBuffer; para2: jint; para3: jint): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function write(var para1: array of JNByteBuffer; para2: jint; para3: jint): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function write(para1: Arr1JNByteBuffer): jlong; overload; virtual; final; // throws java.io.IOException
|
||||
function write(var para1: array of JNByteBuffer): jlong; overload; virtual; final; // throws java.io.IOException
|
||||
function position(): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function position(para1: jlong): JNCFileChannel; overload; virtual; abstract; // throws java.io.IOException
|
||||
function size(): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function truncate(para1: jlong): JNCFileChannel; overload; virtual; abstract; // throws java.io.IOException
|
||||
procedure force(para1: jboolean); overload; virtual; abstract; // throws java.io.IOException
|
||||
function transferTo(para1: jlong; para2: jlong; para3: JNCWritableByteChannel): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function transferFrom(para1: JNCReadableByteChannel; para2: jlong; para3: jlong): jlong; overload; virtual; abstract; // throws java.io.IOException
|
||||
function read(para1: JNByteBuffer; para2: jlong): jint; overload; virtual; abstract; // throws java.io.IOException
|
||||
function write(para1: JNByteBuffer; para2: jlong): jint; overload; virtual; abstract; // throws java.io.IOException
|
||||
function map(para1: JNCFileChannel.InnerMapMode; para2: jlong; para3: jlong): JNMappedByteBuffer; overload; virtual; abstract; // throws java.io.IOException
|
||||
function lock(para1: jlong; para2: jlong; para3: jboolean): JNCFileLock; overload; virtual; abstract; // throws java.io.IOException
|
||||
function lock(): JNCFileLock; overload; virtual; final; // throws java.io.IOException
|
||||
function tryLock(para1: jlong; para2: jlong; para3: jboolean): JNCFileLock; overload; virtual; abstract; // throws java.io.IOException
|
||||
function tryLock(): JNCFileLock; overload; virtual; final; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIFileDescriptor = class sealed external 'java.io' name 'FileDescriptor' (JLObject)
|
||||
public
|
||||
final class var
|
||||
fin: JIFileDescriptor; external name 'in';
|
||||
fout: JIFileDescriptor; external name 'out';
|
||||
ferr: JIFileDescriptor; external name 'err';
|
||||
public
|
||||
constructor create(); overload;
|
||||
function valid(): jboolean; overload; virtual;
|
||||
procedure sync(); overload; virtual; // throws java.io.SyncFailedException
|
||||
end;
|
||||
|
||||
JIInputStream = class abstract external 'java.io' name 'InputStream' (JLObject, JICloseable)
|
||||
public
|
||||
constructor create(); overload;
|
||||
function read(): jint; overload; virtual; abstract; // throws java.io.IOException
|
||||
function read(para1: Arr1jbyte): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(var para1: array of jbyte): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(para1: Arr1jbyte; para2: jint; para3: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(var para1: array of jbyte; para2: jint; para3: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
function skip(para1: jlong): jlong; overload; virtual; // throws java.io.IOException
|
||||
function available(): jint; overload; virtual; // throws java.io.IOException
|
||||
procedure close(); overload; virtual; // throws java.io.IOException
|
||||
procedure mark(para1: jint); overload; virtual;
|
||||
procedure reset(); overload; virtual; // throws java.io.IOException
|
||||
function markSupported(): jboolean; overload; virtual;
|
||||
end;
|
||||
|
||||
JIOutputStream = class abstract external 'java.io' name 'OutputStream' (JLObject, JICloseable, JIFlushable)
|
||||
public
|
||||
constructor create(); overload;
|
||||
procedure write(para1: jint); overload; virtual; abstract; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure flush(); overload; virtual; // throws java.io.IOException
|
||||
procedure close(); overload; virtual; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIFileOutputStream = class external 'java.io' name 'FileOutputStream' (JIOutputStream)
|
||||
public
|
||||
constructor create(para1: JLString); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JLString; para2: jboolean); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFile); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFile; para2: jboolean); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFileDescriptor); overload;
|
||||
procedure write(para1: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure close(); overload; virtual; // throws java.io.IOException
|
||||
function getFD(): JIFileDescriptor; overload; virtual; final; // throws java.io.IOException
|
||||
function getChannel(): JNCFileChannel; overload; virtual;
|
||||
strict protected
|
||||
procedure finalize(); overload; virtual; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIFileInputStream = class external 'java.io' name 'FileInputStream' (JIInputStream)
|
||||
public
|
||||
constructor create(para1: JLString); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFile); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFileDescriptor); overload;
|
||||
function read(): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(para1: Arr1jbyte): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(var para1: array of jbyte): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(para1: Arr1jbyte; para2: jint; para3: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(var para1: array of jbyte; para2: jint; para3: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
function skip(para1: jlong): jlong; overload; virtual; // throws java.io.IOException
|
||||
function available(): jint; overload; virtual; // throws java.io.IOException
|
||||
procedure close(); overload; virtual; // throws java.io.IOException
|
||||
function getFD(): JIFileDescriptor; overload; virtual; final; // throws java.io.IOException
|
||||
function getChannel(): JNCFileChannel; overload; virtual;
|
||||
strict protected
|
||||
procedure finalize(); overload; virtual; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIRandomAccessFile = class external 'java.io' name 'RandomAccessFile' (JLObject, JIDataOutput, JIDataInput, JICloseable)
|
||||
public
|
||||
constructor create(para1: JLString; para2: JLString); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFile; para2: JLString); overload; // throws java.io.FileNotFoundException
|
||||
function getFD(): JIFileDescriptor; overload; virtual; final; // throws java.io.IOException
|
||||
function getChannel(): JNCFileChannel; overload; virtual; final;
|
||||
function read(): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(para1: Arr1jbyte; para2: jint; para3: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(var para1: array of jbyte; para2: jint; para3: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(para1: Arr1jbyte): jint; overload; virtual; // throws java.io.IOException
|
||||
function read(var para1: array of jbyte): jint; overload; virtual; // throws java.io.IOException
|
||||
procedure readFully(para1: Arr1jbyte); overload; virtual; final; // throws java.io.IOException
|
||||
procedure readFully(var para1: array of jbyte); overload; virtual; final; // throws java.io.IOException
|
||||
procedure readFully(para1: Arr1jbyte; para2: jint; para3: jint); overload; virtual; final; // throws java.io.IOException
|
||||
procedure readFully(var para1: array of jbyte; para2: jint; para3: jint); overload; virtual; final; // throws java.io.IOException
|
||||
function skipBytes(para1: jint): jint; overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
function getFilePointer(): jlong; overload; virtual; // throws java.io.IOException
|
||||
procedure seek(para1: jlong); overload; virtual; // throws java.io.IOException
|
||||
function length(): jlong; overload; virtual; // throws java.io.IOException
|
||||
procedure setLength(para1: jlong); overload; virtual; // throws java.io.IOException
|
||||
procedure close(); overload; virtual; // throws java.io.IOException
|
||||
function readBoolean(): jboolean; overload; virtual; final; // throws java.io.IOException
|
||||
function readByte(): jbyte; overload; virtual; final; // throws java.io.IOException
|
||||
function readUnsignedByte(): jint; overload; virtual; final; // throws java.io.IOException
|
||||
function readShort(): jshort; overload; virtual; final; // throws java.io.IOException
|
||||
function readUnsignedShort(): jint; overload; virtual; final; // throws java.io.IOException
|
||||
function readChar(): jchar; overload; virtual; final; // throws java.io.IOException
|
||||
function readInt(): jint; overload; virtual; final; // throws java.io.IOException
|
||||
function readLong(): jlong; overload; virtual; final; // throws java.io.IOException
|
||||
function readFloat(): jfloat; overload; virtual; final; // throws java.io.IOException
|
||||
function readDouble(): jdouble; overload; virtual; final; // throws java.io.IOException
|
||||
function readLine(): JLString; overload; virtual; final; // throws java.io.IOException
|
||||
function readUTF(): JLString; overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeBoolean(para1: jboolean); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeByte(para1: jint); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeShort(para1: jint); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeChar(para1: jint); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeInt(para1: jint); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeLong(para1: jlong); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeFloat(para1: jfloat); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeDouble(para1: jdouble); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeBytes(para1: JLString); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeChars(para1: JLString); overload; virtual; final; // throws java.io.IOException
|
||||
procedure writeUTF(para1: JLString); overload; virtual; final; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIFilterOutputStream = class external 'java.io' name 'FilterOutputStream' (JIOutputStream)
|
||||
strict protected
|
||||
var
|
||||
fout: JIOutputStream; external name 'out';
|
||||
public
|
||||
constructor create(para1: JIOutputStream); overload;
|
||||
procedure write(para1: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte); overload; virtual; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte; para2: jint; para3: jint); overload; virtual; // throws java.io.IOException
|
||||
procedure flush(); overload; virtual; // throws java.io.IOException
|
||||
procedure close(); overload; virtual; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
|
||||
JIPrintStream = class external 'java.io' name 'PrintStream' (JIFilterOutputStream, JLAppendable, JICloseable)
|
||||
public
|
||||
constructor create(para1: JIOutputStream); overload;
|
||||
constructor create(para1: JIOutputStream; para2: jboolean); overload;
|
||||
constructor create(para1: JIOutputStream; para2: jboolean; para3: JLString); overload; // throws java.io.UnsupportedEncodingException
|
||||
constructor create(para1: JLString); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JLString; para2: JLString); overload; // throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException
|
||||
constructor create(para1: JIFile); overload; // throws java.io.FileNotFoundException
|
||||
constructor create(para1: JIFile; para2: JLString); overload; // throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException
|
||||
procedure flush(); overload; virtual;
|
||||
procedure close(); overload; virtual;
|
||||
function checkError(): jboolean; overload; virtual;
|
||||
strict protected
|
||||
procedure setError(); overload; virtual;
|
||||
procedure clearError(); overload; virtual;
|
||||
public
|
||||
procedure write(para1: jint); overload; virtual;
|
||||
procedure write(para1: Arr1jbyte; para2: jint; para3: jint); overload; virtual;
|
||||
procedure write(var para1: array of jbyte; para2: jint; para3: jint); overload; virtual;
|
||||
procedure print(para1: jboolean); overload; virtual;
|
||||
procedure print(para1: jchar); overload; virtual;
|
||||
procedure print(para1: jint); overload; virtual;
|
||||
procedure print(para1: jlong); overload; virtual;
|
||||
procedure print(para1: jfloat); overload; virtual;
|
||||
procedure print(para1: jdouble); overload; virtual;
|
||||
procedure print(para1: Arr1jchar); overload; virtual;
|
||||
procedure print(var para1: array of jchar); overload; virtual;
|
||||
procedure print(para1: JLString); overload; virtual;
|
||||
procedure print(para1: JLObject); overload; virtual;
|
||||
procedure println(); overload; virtual;
|
||||
procedure println(para1: jboolean); overload; virtual;
|
||||
procedure println(para1: jchar); overload; virtual;
|
||||
procedure println(para1: jint); overload; virtual;
|
||||
procedure println(para1: jlong); overload; virtual;
|
||||
procedure println(para1: jfloat); overload; virtual;
|
||||
procedure println(para1: jdouble); overload; virtual;
|
||||
procedure println(para1: Arr1jchar); overload; virtual;
|
||||
procedure println(var para1: array of jchar); overload; virtual;
|
||||
procedure println(para1: JLString); overload; virtual;
|
||||
procedure println(para1: JLObject); overload; virtual;
|
||||
function printf(para1: JLString; para2: Arr1JLObject): JIPrintStream; overload; virtual;
|
||||
function printf(para1: JLString; const para2: array of JLObject): JIPrintStream; overload; virtual;
|
||||
function printf(para1: JULocale; para2: JLString; para3: Arr1JLObject): JIPrintStream; overload; virtual;
|
||||
function printf(para1: JULocale; para2: JLString; const para3: array of JLObject): JIPrintStream; overload; virtual;
|
||||
function format(para1: JLString; para2: Arr1JLObject): JIPrintStream; overload; virtual;
|
||||
function format(para1: JLString; const para2: array of JLObject): JIPrintStream; overload; virtual;
|
||||
function format(para1: JULocale; para2: JLString; para3: Arr1JLObject): JIPrintStream; overload; virtual;
|
||||
function format(para1: JULocale; para2: JLString; const para3: array of JLObject): JIPrintStream; overload; virtual;
|
||||
function append(para1: JLCharSequence): JIPrintStream; overload; virtual;
|
||||
function append(para1: JLCharSequence; para2: jint; para3: jint): JIPrintStream; overload; virtual;
|
||||
function append(para1: jchar): JIPrintStream; overload; virtual;
|
||||
function append(para1: jchar): JLAppendable; overload; virtual; // throws java.io.IOException
|
||||
function append(para1: JLCharSequence; para2: jint; para3: jint): JLAppendable; overload; virtual; // throws java.io.IOException
|
||||
function append(para1: JLCharSequence): JLAppendable; overload; virtual; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
|
@ -443,7 +443,7 @@ type
|
||||
Arr2JNIntBuffer = array of Arr1JNIntBuffer;
|
||||
Arr3JNIntBuffer = array of Arr2JNIntBuffer;
|
||||
|
||||
JIInputStream = class external 'java.io' name 'InputStream';
|
||||
JIInputStream = class;
|
||||
Arr1JIInputStream = array of JIInputStream;
|
||||
Arr2JIInputStream = array of Arr1JIInputStream;
|
||||
Arr3JIInputStream = array of Arr2JIInputStream;
|
||||
@ -478,7 +478,7 @@ type
|
||||
Arr2JURandom = array of Arr1JURandom;
|
||||
Arr3JURandom = array of Arr2JURandom;
|
||||
|
||||
JIOutputStream = class external 'java.io' name 'OutputStream';
|
||||
JIOutputStream = class;
|
||||
Arr1JIOutputStream = array of JIOutputStream;
|
||||
Arr2JIOutputStream = array of Arr1JIOutputStream;
|
||||
Arr3JIOutputStream = array of Arr2JIOutputStream;
|
||||
@ -488,10 +488,6 @@ type
|
||||
Arr2JLStackTraceElement = array of Arr1JLStackTraceElement;
|
||||
Arr3JLStackTraceElement = array of Arr2JLStackTraceElement;
|
||||
|
||||
JIFile = class external 'java.io' name 'File';
|
||||
Arr1JIFile = array of JIFile;
|
||||
Arr2JIFile = array of Arr1JIFile;
|
||||
Arr3JIFile = array of Arr2JIFile;
|
||||
|
||||
JUProperties = class external 'java.util' name 'Properties';
|
||||
Arr1JUProperties = array of JUProperties;
|
||||
@ -513,7 +509,7 @@ type
|
||||
Arr2JSProtectionDomain = array of Arr1JSProtectionDomain;
|
||||
Arr3JSProtectionDomain = array of Arr2JSProtectionDomain;
|
||||
|
||||
JIPrintStream = class external 'java.io' name 'PrintStream';
|
||||
JIPrintStream = class ;
|
||||
Arr1JIPrintStream = array of JIPrintStream;
|
||||
Arr2JIPrintStream = array of Arr1JIPrintStream;
|
||||
Arr3JIPrintStream = array of Arr2JIPrintStream;
|
||||
@ -563,7 +559,14 @@ type
|
||||
Arr2JLAAnnotation = array of Arr1JLAAnnotation;
|
||||
Arr3JLAAnnotation = array of Arr2JLAAnnotation;
|
||||
|
||||
JNCChannel = interface external 'java.nio.channels' name 'Channel';
|
||||
JICloseable = interface external 'java.io' name 'Closeable'
|
||||
procedure close(); overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JNCChannel = interface external 'java.nio.channels' name 'Channel' (JICloseable)
|
||||
function isOpen(): jboolean; overload;
|
||||
procedure close(); overload; // throws java.io.IOException
|
||||
end;
|
||||
Arr1JNCChannel = array of JNCChannel;
|
||||
Arr2JNCChannel = array of Arr1JNCChannel;
|
||||
Arr3JNCChannel = array of Arr2JNCChannel;
|
||||
@ -578,4 +581,76 @@ type
|
||||
Arr2JUSortedMap = array of Arr1JUSortedMap;
|
||||
Arr3JUSortedMap = array of Arr2JUSortedMap;
|
||||
|
||||
JIFile = Class;
|
||||
Arr1JIFile = array of JIFile;
|
||||
Arr2JIFile = array of Arr1JIFile;
|
||||
Arr3JIFile = array of Arr2JIFile;
|
||||
|
||||
JNCFileChannel = class;
|
||||
|
||||
JNCSAbstractInterruptibleChannel = class;
|
||||
|
||||
JNCInterruptibleChannel = interface external 'java.nio.channels' name 'InterruptibleChannel' (JNCChannel)
|
||||
procedure close(); overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIFilenameFilter = interface external 'java.io' name 'FilenameFilter'
|
||||
function accept(para1: JIFile; para2: JLString): jboolean; overload;
|
||||
end;
|
||||
|
||||
JIFileFilter = interface external 'java.io' name 'FileFilter'
|
||||
function accept(para1: JIFile): jboolean; overload;
|
||||
end;
|
||||
|
||||
|
||||
JNCReadableByteChannel = interface external 'java.nio.channels' name 'ReadableByteChannel' (JNCChannel)
|
||||
function read(para1: JNByteBuffer): jint; overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JNCWritableByteChannel = interface external 'java.nio.channels' name 'WritableByteChannel' (JNCChannel)
|
||||
function write(para1: JNByteBuffer): jint; overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIFlushable = interface external 'java.io' name 'Flushable'
|
||||
procedure flush(); overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIDataInput = interface external 'java.io' name 'DataInput'
|
||||
procedure readFully(para1: Arr1jbyte); overload; // throws java.io.IOException
|
||||
procedure readFully(var para1: array of jbyte); overload; // throws java.io.IOException
|
||||
procedure readFully(para1: Arr1jbyte; para2: jint; para3: jint); overload; // throws java.io.IOException
|
||||
procedure readFully(var para1: array of jbyte; para2: jint; para3: jint); overload; // throws java.io.IOException
|
||||
function skipBytes(para1: jint): jint; overload; // throws java.io.IOException
|
||||
function readBoolean(): jboolean; overload; // throws java.io.IOException
|
||||
function readByte(): jbyte; overload; // throws java.io.IOException
|
||||
function readUnsignedByte(): jint; overload; // throws java.io.IOException
|
||||
function readShort(): jshort; overload; // throws java.io.IOException
|
||||
function readUnsignedShort(): jint; overload; // throws java.io.IOException
|
||||
function readChar(): jchar; overload; // throws java.io.IOException
|
||||
function readInt(): jint; overload; // throws java.io.IOException
|
||||
function readLong(): jlong; overload; // throws java.io.IOException
|
||||
function readFloat(): jfloat; overload; // throws java.io.IOException
|
||||
function readDouble(): jdouble; overload; // throws java.io.IOException
|
||||
function readLine(): JLString; overload; // throws java.io.IOException
|
||||
function readUTF(): JLString; overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
JIDataOutput = interface external 'java.io' name 'DataOutput'
|
||||
procedure write(para1: jint); overload; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte); overload; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte); overload; // throws java.io.IOException
|
||||
procedure write(para1: Arr1jbyte; para2: jint; para3: jint); overload; // throws java.io.IOException
|
||||
procedure write(var para1: array of jbyte; para2: jint; para3: jint); overload; // throws java.io.IOException
|
||||
procedure writeBoolean(para1: jboolean); overload; // throws java.io.IOException
|
||||
procedure writeByte(para1: jint); overload; // throws java.io.IOException
|
||||
procedure writeShort(para1: jint); overload; // throws java.io.IOException
|
||||
procedure writeChar(para1: jint); overload; // throws java.io.IOException
|
||||
procedure writeInt(para1: jint); overload; // throws java.io.IOException
|
||||
procedure writeLong(para1: jlong); overload; // throws java.io.IOException
|
||||
procedure writeFloat(para1: jfloat); overload; // throws java.io.IOException
|
||||
procedure writeDouble(para1: jdouble); overload; // throws java.io.IOException
|
||||
procedure writeBytes(para1: JLString); overload; // throws java.io.IOException
|
||||
procedure writeChars(para1: JLString); overload; // throws java.io.IOException
|
||||
procedure writeUTF(para1: JLString); overload; // throws java.io.IOException
|
||||
end;
|
||||
|
||||
|
@ -583,9 +583,12 @@ procedure fpc_Read_Text_Int64_Iso(var f : text; out i : int64); compilerproc;
|
||||
Procedure fpc_Read_Text_LongWord(var f : text; out q : longword); compilerproc;
|
||||
Procedure fpc_Read_Text_LongInt(var f : text; out i : longint); compilerproc;
|
||||
{$endif CPU16 or CPU8}
|
||||
{$ifDEF FPC_HAS_FEATURE_TEXTIO}
|
||||
function fpc_GetBuf_Text(var f : Text) : pchar; compilerproc;
|
||||
function fpc_GetBuf_TypedFile(var f : TypedFile) : pointer; compilerproc;
|
||||
{$endif FPC_HAS_FEATURE_TEXTIO}
|
||||
{$IFDEF FPC_HAS_FEATURE_FILEIO}
|
||||
function fpc_GetBuf_TypedFile(var f : TypedFile) : pointer; compilerproc;
|
||||
{$endif FPC_HAS_FEATURE_FILEIO}
|
||||
|
||||
{$ifdef FPC_INCLUDE_SOFTWARE_MOD_DIV}
|
||||
function fpc_div_dword(n,z : dword) : dword; compilerproc;
|
||||
|
@ -78,6 +78,7 @@ Procedure HandleErrorFrame (Errno : longint;frame : Pointer); forward;
|
||||
Procedure HandleErrorAddrFrame (Errno : longint;addr : CodePointer; frame : Pointer); forward;
|
||||
Procedure HandleErrorAddrFrameInd (Errno : longint;addr : CodePointer; frame : Pointer); forward;
|
||||
|
||||
|
||||
{$ifdef FPC_HAS_FEATURE_TEXTIO}
|
||||
type
|
||||
FileFunc = Procedure(var t : TextRec);
|
||||
|
296
rtl/java/sysfile.inc
Normal file
296
rtl/java/sysfile.inc
Normal file
@ -0,0 +1,296 @@
|
||||
{
|
||||
This file is part of the Free Pascal run time library.
|
||||
|
||||
Main OS dependant body of the system unit, loosely modelled
|
||||
after POSIX. *BSD version (Linux version is near identical)
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
Const
|
||||
UnusedHandle = Nil;
|
||||
DefaultTextLineBreakStyle = tlbsLF;
|
||||
CtrlZMarksEOF: boolean = false;
|
||||
|
||||
|
||||
Procedure Do_Close(Handle:thandle);
|
||||
|
||||
Begin
|
||||
Try
|
||||
(JLObject(Handle) as JICloseable).close();
|
||||
except
|
||||
InoutRes:=1
|
||||
end;
|
||||
End;
|
||||
|
||||
Procedure Do_Erase(p: PFileTextRecChar; pchangeable: boolean);
|
||||
|
||||
var
|
||||
F : JIFile;
|
||||
S : String;
|
||||
|
||||
Begin
|
||||
InoutRes:=0;
|
||||
S:=P;
|
||||
F:=JIFile.Create(S);
|
||||
if Not F.Exists then
|
||||
InoutRes:=2
|
||||
else
|
||||
if F.isDirectory then
|
||||
InoutRes:=2
|
||||
else
|
||||
try
|
||||
F.Delete;
|
||||
except
|
||||
InoutRes:=5;
|
||||
end;
|
||||
End;
|
||||
|
||||
{ truncate at a given position }
|
||||
procedure do_truncate (handle:thandle;fpos:int64);
|
||||
|
||||
Var
|
||||
F : JIFile;
|
||||
C : JNCFileChannel;
|
||||
|
||||
begin
|
||||
InoutRes:=0;
|
||||
try
|
||||
// Will raise an error for stdout, since it is JIPrintStream, not JIFileOutputStream
|
||||
C:=(JLObject(handle) as JIFileOutputStream).getChannel();
|
||||
C.truncate(fpos);
|
||||
except
|
||||
InoutRes:=2;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure Do_Rename(p1 : PFileTextRecChar ; p2:UnicodeString; p1changeable, p2changeable: boolean);
|
||||
|
||||
Var
|
||||
S1,S2 : string;
|
||||
F1,F2 : JIFile;
|
||||
|
||||
Begin
|
||||
S1:=P1;
|
||||
S2:=P2;
|
||||
F1:=JIFile.Create(S1);
|
||||
F2:=JIFile.Create(S2);
|
||||
if not F1.Exists then
|
||||
InoutRes:=2
|
||||
else
|
||||
try
|
||||
F1.RenameTo(F2);
|
||||
InoutRes:=1;
|
||||
except
|
||||
InoutRes:=5;
|
||||
end;
|
||||
End;
|
||||
|
||||
|
||||
Function Do_Write(Handle:thandle;Addr:Pointer;Len:Longint):longint;
|
||||
|
||||
var
|
||||
F : JIOutputStream;
|
||||
|
||||
Begin
|
||||
InoutRes:=0;
|
||||
F:=JIOutputStream(Handle);
|
||||
try
|
||||
F.write(Arr1jbyte(Addr),0,Len);
|
||||
Do_Write:=Len;
|
||||
except
|
||||
InoutRes:=101;
|
||||
end;
|
||||
End;
|
||||
|
||||
|
||||
Function Do_Read(Handle:thandle;Addr:Pointer;Len:Longint):Longint;
|
||||
|
||||
var
|
||||
F : JIInputStream;
|
||||
|
||||
Begin
|
||||
InoutRes:=0;
|
||||
F:=JIInputStream(Handle);
|
||||
try
|
||||
Do_Read:=F.read(Arr1jbyte(Addr),0,Len);
|
||||
except
|
||||
InoutRes:=101;
|
||||
end;
|
||||
End;
|
||||
|
||||
function Do_FilePos(Handle: thandle):Int64;
|
||||
|
||||
Var
|
||||
C : JNCFileChannel;
|
||||
|
||||
Begin
|
||||
Do_FilePos:=0;
|
||||
if JLObject(Handle) is JIFileInputStream then
|
||||
C:=JIFileInputStream(Handle).getChannel()
|
||||
else if JLObject(Handle) is JIFileOutputStream then
|
||||
C:=JIFileOutputStream(Handle).getChannel()
|
||||
else
|
||||
C:=Nil;
|
||||
try
|
||||
if (C<>Nil) then
|
||||
begin
|
||||
Do_FilePos:=C.position();
|
||||
InoutRes:=0;
|
||||
end
|
||||
else
|
||||
InoutRes:=5;
|
||||
except
|
||||
InoutRes:=5;
|
||||
end;
|
||||
End;
|
||||
|
||||
Procedure Do_Seek(Handle:thandle;Pos:Int64);
|
||||
|
||||
Var
|
||||
C : JNCFileChannel;
|
||||
|
||||
Begin
|
||||
if JLObject(Handle) is JIFileInputStream then
|
||||
C:=JIFileInputStream(Handle).getChannel()
|
||||
else
|
||||
C:=JIFileOutputStream(Handle).getChannel();
|
||||
try
|
||||
C.position(Pos);
|
||||
InoutRes:=0;
|
||||
except
|
||||
InoutRes:=5;
|
||||
end;
|
||||
End;
|
||||
|
||||
Function GetChannel(Handle:thandle):JNCFileChannel;
|
||||
|
||||
begin
|
||||
if JLObject(Handle) is JIFileInputStream then
|
||||
GetChannel:=JIFileInputStream(Handle).getChannel()
|
||||
else if JLObject(Handle) is JIFileOutputStream then
|
||||
GetChannel:=JIFileOutputStream(Handle).getChannel()
|
||||
else if JLObject(Handle) is JIRandomAccessFile then
|
||||
GetChannel:=JIRandomAccessFile(Handle).getChannel()
|
||||
else
|
||||
begin
|
||||
GetChannel:=Nil;
|
||||
InoutRes:=5;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function Do_SeekEnd(Handle:thandle):Int64;
|
||||
|
||||
Var
|
||||
C : JNCFileChannel;
|
||||
|
||||
Begin
|
||||
C:=GetChannel(Handle); // Sets inoutres if Nil
|
||||
try
|
||||
if Assigned(C) then
|
||||
begin
|
||||
C.position(C.Size);
|
||||
InoutRes:=0;
|
||||
end
|
||||
except
|
||||
InoutRes:=5;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function Do_FileSize(Handle:thandle):Int64;
|
||||
|
||||
Var
|
||||
C : JNCFileChannel;
|
||||
|
||||
Begin
|
||||
C:=GetChannel(Handle); // Sets inoutres if Nil
|
||||
try
|
||||
if Assigned(C) then
|
||||
begin
|
||||
Result:=C.Size;
|
||||
InoutRes:=0;
|
||||
end
|
||||
except
|
||||
InoutRes:=5;
|
||||
end;
|
||||
End;
|
||||
|
||||
Function Do_IsDevice(Handle : THandle) : boolean;
|
||||
|
||||
begin
|
||||
Result:=JLObject(Handle) is JIPrintStream ;
|
||||
end;
|
||||
|
||||
|
||||
Procedure Do_Open(var F : TextRec; p: PFileTextRecChar; flags: longint; pchangeable: boolean);
|
||||
{
|
||||
FileRec and textrec have both Handle and mode as the first items so
|
||||
they could use the same routine for opening/creating.
|
||||
when (flags and $100) the file will be append
|
||||
when (flags and $1000) the file will be truncate/rewritten
|
||||
when (flags and $10000) there is no check for close (needed for textfiles)
|
||||
}
|
||||
var
|
||||
S : String;
|
||||
Begin
|
||||
S:=p;
|
||||
{ close first if opened }
|
||||
if ((flags and $10000)=0) then
|
||||
begin
|
||||
case f.mode of
|
||||
fminput,fmoutput,fminout : Do_Close(TextRec(f).Handle);
|
||||
fmclosed : ;
|
||||
else
|
||||
begin
|
||||
inoutres:=102; {not assigned}
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{ reset file Handle }
|
||||
f.Handle:=Nil;
|
||||
{ We do the conversion of filemodes here, concentrated on 1 place }
|
||||
case (flags and 3) of
|
||||
0 : begin
|
||||
if S='' then
|
||||
f.Handle:=JLsystem.fin
|
||||
else
|
||||
F.Handle:=JIFileInputStream.create(S);
|
||||
f.mode:=fminput;
|
||||
end;
|
||||
1 : begin
|
||||
if S='' then
|
||||
f.Handle:=JLsystem.fout
|
||||
else
|
||||
F.Handle:=JIFileOutputStream.Create(S,(flags and $100)=$100);
|
||||
f.mode:=fmoutput;
|
||||
end;
|
||||
2 : begin
|
||||
// We may need to check existence first ?
|
||||
F.Handle:=JIRandomAccessFile.Create(S,'rw');
|
||||
if (flags and $100)=$100 then
|
||||
With GetChannel(F.Handle) do
|
||||
Position(Size);
|
||||
f.mode:=fminout;
|
||||
end;
|
||||
end;
|
||||
if (S='') then
|
||||
exit;
|
||||
If f.Handle=Nil Then
|
||||
begin
|
||||
InoutRes:=5;
|
||||
f.mode:=fmclosed;
|
||||
end
|
||||
else
|
||||
InOutRes:=0;
|
||||
End;
|
||||
|
||||
|
@ -23,6 +23,7 @@ Unit System;
|
||||
{*****************************************************************************}
|
||||
|
||||
{$define FPC_IS_SYSTEM}
|
||||
{$define FPC_HAS_FEATURE_TEXTIO}
|
||||
|
||||
{$I-,Q-,H-,R-,V-,P+,T+}
|
||||
{$implicitexceptions off}
|
||||
@ -116,10 +117,24 @@ const
|
||||
{$i jastringh.inc}
|
||||
{$i justringh.inc}
|
||||
|
||||
Type
|
||||
THandle = JLObject;
|
||||
{$i textrec.inc}
|
||||
PText = ^TextRec;
|
||||
Var
|
||||
{ Standard In- and Output }
|
||||
ErrOutput,
|
||||
Output,
|
||||
Input,
|
||||
StdOut,
|
||||
StdErr : Text;
|
||||
InOutRes : Word;
|
||||
|
||||
{$i jsystemh.inc}
|
||||
{$i jtconh.inc}
|
||||
|
||||
|
||||
|
||||
{*****************************************************************************}
|
||||
implementation
|
||||
{*****************************************************************************}
|
||||
@ -132,6 +147,8 @@ function min(a,b : longint) : longint;
|
||||
min:=b;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{$i jtcon.inc}
|
||||
{$i jtvar.inc}
|
||||
{$i jsstrings.inc}
|
||||
@ -141,6 +158,7 @@ function min(a,b : longint) : longint;
|
||||
{$i jset.inc}
|
||||
{$i jpvar.inc}
|
||||
{$i jdynarr.inc}
|
||||
{$i sysfile.inc}
|
||||
{$i jsystem.inc}
|
||||
|
||||
|
||||
@ -177,6 +195,8 @@ procedure fpc_var_copyout_mismatch(line,column: longint); compilerproc;
|
||||
SystemUnit Initialization
|
||||
*****************************************************************************}
|
||||
|
||||
|
||||
|
||||
begin
|
||||
initunicodestringmanager
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user