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

class FileBase in Tinman.Core.IO.Files

Abstract base class for IFile implementations.

abstract class FileBase extends Disposable
  implements IFile
  base of DatasetFile
  File_Memory
  HttpFile
  VirtualFile

Public / Attributes

CanRead

Does this object support read access?

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

CanWrite

Does this binary object support write access?

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

IsTemporary

Is this a temporary file?

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

Remarks:

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

LifecycleState

Returns the lifecycle state of this object.

public virtual property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited Disposable.LifecycleState

PathInfo

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

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

Remarks:

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

Public / Methods

AcquireTry

Acquires a strong reference to this disposable object.

[OwnerReturn, ThreadSafe]
public method AcquireTry ()
type IDisposable
returns this if a new strong reference has been acquired, null if this object is already being disposed.
inherited Disposable.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]
public virtual method Cache (FileCache cache)
type IFile
params cache [not-null] The cache to use.
returns [not-null] The resulting IFile object.
implements 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]
public method Dispose ()
inherited Disposable.Dispose

Remarks:

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

Flush

Flushes all cached data.

public abstract method Flush ()
implements 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]
public abstract method GetLength ()
type int64
returns [>=0] The current length, in bytes.
implements IFile.GetLength

GetTimestamp

Returns the timestamp of the last file modification.

public abstract method GetTimestamp ()
type int64
returns The timestamp value (see SystemTime).
implements IFile.GetTimestamp

Offset

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

[OwnerReturn, OwnerThis]
public virtual 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.
implements IFileOps.Offset

Read

Reads a chunk of bytes from the binary object.

[ThreadSafe]
public abstract 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.
implements IFile.Read

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]
public virtual 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.
implements IFile.ReadAll

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]
public 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.
implements IFileOps.ReadArchive

ReadOnly

Returns a read-only view on this IFile.

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

SetLength

Sets the length of this binary object.

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

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]
public virtual 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.
implements IDataStreamFactory.ToDataStream

Write

Writes a chunk of bytes to the file.

[ThreadSafe]
public abstract 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.
implements IFile.Write

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.

Protected / Methods

DisposeManaged

Disposes the managed resources held by a concrete subclass. This method will be called at most once per subclass.

protected virtual method DisposeManaged ()
inherited Disposable.DisposeManaged

Remarks:

This method will only be called when a disposable object is explicitly destroyed by user code calling the Dispose method. It will not be called when the object is collected as garbage by the system.

Overriding methods must call the DisposeManaged method of their base class. The base call should be the last statement.

The DisposeManaged method is called before the DisposeUnmanaged method.

DisposeUnmanaged

Disposes the unmanaged resources held by a concrete subclass. This method will be called exactly once per subclass.

protected virtual method DisposeUnmanaged ()
inherited Disposable.DisposeUnmanaged

Remarks:

Overriding methods must call the DisposeUnmanaged method of their base class. The base call should be the last statement.

The DisposeUnmanaged method is called after the DisposeManaged method.

ResolveBufferOffset

protected static method ResolveBufferOffset (ByteBuffer buffer, int32 bufferOffset)
type int32
params buffer
  bufferOffset

ResolveCount

protected static method ResolveCount (ByteBuffer buffer, int32 count)
type int32
params buffer
  count