TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

interface IFile in Tinman.Core.IO.Files

Base interface for classes that represent binary objects with random-access semantics.

interface IFile extends ICanReadWrite
  IDisposable
  IFileOps
  IFlushable
  IPathInfo
  base of FileBase

Attributes

CanRead

Does this object support read access?

property CanRead { get }
type bool
value true if this object supports reading, false if not.
inherited ICanReadWrite.CanRead

CanWrite

Does this binary object support write access?

property CanWrite { get }
type bool
value true if this object supports writing, false if not.
inherited ICanReadWrite.CanWrite

IsTemporary

Is this a temporary file?

property IsTemporary { get }
type bool
value true if this file is a temporary one, false if it is a regular one.

Remarks:

The contents of a temporary file are no longer used when it is disposed.

LifecycleState

Returns the lifecycle state of this object.

property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited ILifecycleState.LifecycleState

PathInfo

Returns a Path object that represents the file path this object is associated with.

property PathInfo { get }
type Path
value [not-null] The path info.
inherited IPathInfo.PathInfo

Remarks:

Objects that do not have a meaningful file path association simply return Unknown.

Methods

AcquireTry

Acquires a strong reference to this disposable object.

[OwnerReturn, ThreadSafe]
method AcquireTry ()
type IDisposable
returns this if a new strong reference has been acquired, null if this object is already being disposed.
inherited IDisposable.AcquireTry

Remarks:

The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.

This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.

Cache

Returns a IFile that accesses this file through the given in-memory file cache.

[OwnerReturn, OwnerThis]
method Cache (FileCache cache)
type IFile
params cache [not-null] The cache to use.
returns [not-null] The resulting IFile object.
inherited IFileOps.Cache

Dispose

Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.

[Dispose, OwnerThis, ThreadSafe]
method Dispose ()
inherited IDisposable.Dispose

Remarks:

The Dispose method silently returns if the object has already been disposed.

Flush

Flushes all cached data.

method Flush ()
inherited IFlushable.Flush

Remarks:

Performing a flush may result in I/O work. Depending on the semantics of the implementing class, this work may need to be wrapped in special Begin / End method calls. See the documentation of the implementing classes for details.

In case this object represents a read-only resource, calling the Flush method has no effect.

GetLength

Returns the current length of this binary object.

[ThreadSafe]
method GetLength ()
type int64
returns [>=0] The current length, in bytes.

GetTimestamp

Returns the timestamp of the last file modification.

method GetTimestamp ()
type int64
returns The timestamp value (see SystemTime).

Offset

Returns a IFile that accesses the data in this file using the given byte offset.

[OwnerReturn, OwnerThis]
method Offset (int64 offset)
type IFile
params offset [>=0] Absolute offset in this file that will be mapped to offset 0 in the returned file.
returns [not-null] The resulting IFile object.
inherited IFileOps.Offset

Read

Reads a chunk of bytes from the binary object.

[ThreadSafe]
method Read (int64 offset, ByteBuffer buffer, int32 bufferOffset = -1, int32 count = -1)
type int32
params offset [>=0] Offset of first byte to read from file.
  buffer [not-null] The output buffer. The ByteBuffer object will not be modified by this method. The current buffer position (see Position) will be queried iff bufferOffset is -1. The current buffer limit will be queried iff count is -1.
  bufferOffset [>=-1] Offset into output buffer. If set to -1, the current buffer position (see Position) will be used.
  count [>=-1] Total number of bytes to read. If set to -1, the remaining buffer bytes (see Remaining) will be used.
returns [>=0] The actual number of read bytes.

Remarks:

The actual number of read bytes may be lower than count when reading over the end of the binary object. The maximum number of bytes that can be read with a single call is 2^31-1.

ReadAll

Reads a chunk of bytes from the binary object.

[ThreadSafe]
method ReadAll (int64 offset, ByteBuffer buffer, int32 bufferOffset = -1, int32 count = -1)
params offset [>=0] Offset of first byte to read from file.
  buffer [not-null] The output buffer. The ByteBuffer object will not be modified by this method.
  bufferOffset [>=-1] Offset into output buffer. If set to -1, the current buffer position (see Position) will be used.
  count [>=-1] Total number of bytes to read. If set to -1, the remaining buffer bytes (see Remaining) will be used.

Remarks:

The maximum number of bytes that can be read with a single call is 2^31-1.

ReadArchive

Reads the file content as an archive.

[OwnerReturn]
method ReadArchive (string entry = null)
type IDataStream
params entry Name of the archive entry to read or null to read the first entry.
returns [not-null] The data stream that reads the uncompressed archive entry.
inherited IFileOps.ReadArchive

ReadOnly

Returns a read-only view on this IFile.

[OwnerReturn, OwnerThis]
method ReadOnly ()
type IFile
returns [not-null] The resulting IFile object.
inherited IFileOps.ReadOnly

SetLength

Sets the length of this binary object.

[ThreadSafe]
method SetLength (int64 value)
params value [>=0] The new length, in bytes.

Remarks:

Setting the length of a binary object may cause additional management overhead by the OS and should only be done when absolutely necessary.

ToDataStream

Creates an IDataStream object for accessing the data of this object.

[OwnerReturn, OwnerThis]
method ToDataStream (int32 bufferSize = 65536, bool needLength = true)
type IDataStream
params bufferSize [>0] The buffer size to use, in bytes. Defaults to 65536.
  needLength Shall the returned data stream report a proper length (if possible) with its Length property? Defaults to true.
returns [not-null] The data stream.
inherited IDataStreamFactory.ToDataStream

Write

Writes a chunk of bytes to the file.

[ThreadSafe]
method Write (int64 offset, ByteBuffer buffer, int32 bufferOffset = -1, int32 count = -1)
params offset [>=0] Offset of first byte to read from file.
  buffer [not-null] The input buffer. The ByteBuffer object will not be modified by this method.
  bufferOffset [>=-1] Offset into output buffer. If set to -1, the current buffer position (see Position) will be used.
  count [>=-1] Total number of bytes to read. If set to -1, the remaining buffer bytes (see Remaining) will be used.

Remarks:

The maximum number of bytes that can be written with a single call is 2^31-1. Writing past the end of the binary object will cause it to grow automatically.