A file in a VirtualFileSystem.
sealed class
|
VirtualFile
|
extends
|
FileBase
|
Returns the number of bytes that have been read from this file.
public
property
|
BytesRead
{
get
}
|
||
type
|
int64
|
||
value
|
|
The number of read bytes. |
See also:
BytesResetReturns the number of bytes that have been read from or written to this file.
public
property
|
BytesTotal
{
get
}
|
||
type
|
int64
|
||
value
|
|
The number of read and written bytes. |
See also:
BytesResetReturns the number of bytes that have been written to this file.
public
property
|
BytesWritten
{
get
}
|
||
type
|
int64
|
||
value
|
|
The number of written bytes. |
Does this object support read access?
public
virtual
property
|
CanRead
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
object
supports
reading,
false
if
not. |
||
inherited
|
FileBase.CanRead
|
Does this binary object support write access?
public
override
property
|
CanWrite
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
object
supports
writing,
false
if
not. |
||
overrides
|
FileBase.CanWrite
|
Is this virtual file being streamed from the web?
public
property
|
IsHttp
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
file
is
streamed
via
HTTP
or
HTTPS ,
false
if
not.
|
See also:
HttpFileSystemIs this a temporary file?
public
override
property
|
IsTemporary
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
file
is
a
temporary
one,
false
if
it
is
a
regular
one.
|
||
overrides
|
FileBase.IsTemporary
|
Remarks:
The contents of a temporary file are no longer used when it is disposed.
Timestamp of most recent access to this file (i.e. Read or Write).
public
property
|
LastAccess
{
get
}
|
||
type
|
int64
|
||
value
|
The timestamp (see SystemTime). |
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns a Path object that represents the file path this object is associated with.
public
override
property
|
PathInfo
{
get
}
|
||
type
|
Path
|
||
value
|
|
The path info. | |
overrides
|
FileBase.PathInfo
|
Remarks:
Objects that do not have a meaningful file path association simply return Unknown.
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.
Resets the byte counters for this file.
public
method
|
BytesReset
()
|
See also:
BytesReadReturns 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
|
|
The resulting IFile object. | ||
inherited
|
FileBase.Cache
|
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.
Flushes all cached data.
public
override
method
|
Flush
()
|
||
implements
|
FileBase.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.
Returns the current length of this binary object.
[ThreadSafe]
|
||||
public
override
method
|
GetLength
()
|
|||
type
|
int64
|
|||
returns
|
|
The current length, in bytes. | ||
implements
|
FileBase.GetLength
|
Returns the timestamp of the last file modification.
public
override
method
|
GetTimestamp
()
|
||
type
|
int64
|
||
returns
|
The timestamp value (see SystemTime). | ||
implements
|
FileBase.GetTimestamp
|
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
|
|
The resulting IFile object. | ||
inherited
|
FileBase.Offset
|
Reads a chunk of bytes from the binary object.
[ThreadSafe]
|
||||
public
override
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
|
|
The actual number of read bytes. | ||
implements
|
FileBase.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
.
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.
|
||
inherited
|
FileBase.ReadAll
|
Remarks:
The
maximum
number
of
bytes
that
can
be
read
with
a
single
call
is
2^31-1
.
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
|
|
The data stream that reads the uncompressed archive entry. | ||
inherited
|
FileBase.ReadArchive
|
Returns a read-only view on this IFile.
[OwnerReturn, OwnerThis]
|
||||
public
virtual
method
|
ReadOnly
()
|
|||
type
|
IFile
|
|||
returns
|
|
The resulting IFile object. | ||
inherited
|
FileBase.ReadOnly
|
Sets the length of this binary object.
[ThreadSafe]
|
||||
public
override
method
|
SetLength
(int64 value)
|
|||
params
|
value
|
[>=0]
|
The new length, in bytes. | |
implements
|
FileBase.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.
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
|
|
The data stream. | ||
inherited
|
FileBase.ToDataStream
|
Writes a chunk of bytes to the file.
[ThreadSafe]
|
||||
public
override
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
|
FileBase.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.