Mono.Posix
1.0.5000.0
2.0.0.0
4.0.0.0
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
System.IO.Stream
A wrapper over Unix file
descriptors.
is used for reading from and
writing to Unix file descriptors.
objects may support
random access to files using the
method (it depends on whether the underlying file descriptor supports
seeking), and the
properties of
instances
encapsulating file descriptors are set depending on the capabilities
of the underlying file descriptor.
The
method allows the read/write position to be moved to any position
within the file. This is done with byte offset reference point
parameters. The byte offset is relative to the seek reference point,
which can be the beginning, the current position, or the end of the
underlying file, as represented by the three values of the
enumeration.
If a encapsulates a
device that does not support seeking, its
property is
.
For additional information, see
.
The following example demonstrates the use of a
object.
using System;
using System.IO;
using Mono.Unix;
using Mono.Unix.Native;
class Directory {
public static void Main(string[] args) {
int fd = Syscall.open ("log.txt",
OpenFlags.O_WRONLY | OpenFlags.O_CREAT |
OpenFlags.O_APPEND | OpenFlags.O_LARGEFILE);
UnixStream fs = new UnixStream (fd);
StreamWriter w = new StreamWriter(fs);
Log ("Test1", w);
Log ("Test2", w);
w.Close(); // Close the writer and underlying file.
fd = Syscall.open ("log.txt",
OpenFlags.O_RDONLY | OpenFlags.O_LARGEFILE);
fs = new UnixStream(fd);
StreamReader r = new StreamReader(fs);
r.BaseStream.Seek(0, SeekOrigin.Begin);
DumpLog (r);
}
public static void Log (string logMessage, StreamWriter w) {
w.Write("Log Entry : ");
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString());
w.WriteLine(":");
w.WriteLine(":{0}", logMessage);
w.WriteLine ("-------------------------------");
w.Flush();
}
public static void DumpLog (StreamReader r) {
while (r.Peek() > -1) { // While not at the end of the file, write to standard output.
Console.WriteLine(r.ReadLine());
}
r.Close();
}
}
Some example output is
Log Entry : 9:26:21 AM Friday, July 06, 2001
:
:Test1
-------------------------------
Log Entry : 9:26:21 AM Friday, July 06, 2001
:
:Test2
-------------------------------
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing a file descriptor.
Creates and initializes a
instance, wrapping the specified file descriptor
.
By default, is owned by the
created instance.
is equal to
.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing a file descriptor.
A specifying whether or not the
created instance "owns"
.
Creates and initializes a
instance, wrapping the specified file descriptor
.
If is ,
then will be closed via
when
is invoked (which
is also called from the finalizer and from the
implementation). Otherwise,
will only be flushed on
and not actually
closed.
is equal to
.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A containing the file
access pattern to suggest.
Advises a file access pattern for a file stream.
AdviseFileAccessPattern is used to announce an intention
to access file data with a specific pattern, allowing the kernel to
perform appropriate optimizations.
applies to a region starting at
and extending for
bytes (or until end-of-file if is 0)
within the file specified by . The specified
region need not currently exist.
The specified pattern is not binding; it merely constitutes an
expectation on behalf of the application.
is not a valid file stream.
-or-
is not a value.
is .
The stream has been closed.
refers to a pipe or FIFO.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A containing the file
access pattern to suggest.
A containing the start of the range to suggest
the access pattern.
A containing the length of the range
to suggest the
access pattern. If 0, is suggested
until end-of-file.
Advises a file access pattern for a file stream.
AdviseFileAccessPattern is used to announce an intention
to access file data with a specific pattern, allowing the kernel to
perform appropriate optimizations.
applies to a region starting at
and extending for
bytes (or until end-of-file if is 0)
within the file specified by . The specified
region need not currently exist.
The specified pattern is not binding; it merely constitutes an
expectation on behalf of the application.
is not a valid file stream.
-or-
is not a value.
is .
The stream has been closed.
refers to a pipe or FIFO.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
Mono.Unix.FileAccessPermissions
Gets or sets the file system entry access permissions.
A value which
controls access to the file system entry.
The stream has been closed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
Mono.Unix.FileSpecialAttributes
Gets or sets the file system entry special attributes.
A value which
contains the file special attributes to use.
Callers may need to be the super user (often the root
user) to change the file special attributes.
The stream has been closed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
Mono.Unix.FileTypes
Gets the type of this file system entry.
A value specifying the type
of this file system entry.
The stream has been closed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.CLSCompliant(false)
System.Int64
A
value specifying which configuration value to retreive.
Gets a configurable system limit or option variable
associated with
.
A containing the value
of the configuration variable .
If there is no value for the configuration variable
, then -1 is returned.
The implementation does not support an association of
with
.
The stream has been closed.
An I/O error occurred while reading from or writing to the file
system.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
The underlying file descriptor.
A containing the underlying file
descriptor value.
The stream has been closed.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
-1
An invalid file descriptor.
This is the value -1.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int64
To be added.
To be added.
To be added.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
Mono.Unix.UnixGroupInfo
Gets information about the owner group.
A instance containing
information about the owner group.
This is identical to ().
The stream has been closed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int64
Gets the owner group id.
A containing the owner group id.
The stream has been closed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
Mono.Unix.UnixUserInfo
Gets information about the owner user.
A containing information
about the owner user.
This is identical to ().
The stream has been closed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int64
Gets the owner user id.
A containing the owner user id.
The stream has been closed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int64
To be added.
To be added.
To be added.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.CLSCompliant(false)
Mono.Unix.Native.FilePermissions
Gets or sets the file system entry protection.
A value
containing the file system entry protection.
The stream has been closed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
A array. When this method returns, the
elements between and
are replaced by the bytes read
from the current source.
A that specifies the zero-based byte
offset within at which to begin storing
the data read from the current stream.
A that specifies the maximum number of
bytes to be read from the current stream.
A specifying the byte offset within
the file to begin reading.
Reads a sequence of bytes from the current stream without
advancing the position within the stream.
A that specifies the number of bytes
read into the buffer, or zero if the end of the stream has been
reached before any data can be read.
Unlike , this method does
not modify .
Use the property to
determine whether the current instance supports reading.
is greater than the length of
.
is .
or is negative.
The file descriptor is associated with a file system and file type that
do not allow regular read operations on it.
[]
The stream does not support reading.
The stream has been closed.
The file descriptor is associated with a regular file,
is greater than 0,
is before the end-of-file, and
is greater than or equal to the offset maximum established
for this file system.
[]
The file descriptor is associated with a directory residing
on a file system that does not allow regular read operations on
directories (e.g.NFS).
[]
An I/O error occurred while reading from the file system.
[]
-or-
The file descriptor is associated with a pipe, socket, or FIFO.
[]
The file was marked for non-blocking I/O,
and no data were ready to be read.
[]
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int64
To be added.
To be added.
To be added.
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A specifying where to copy the
current stream contents to.
Copies all the data from this stream to the specified
.
This performs an in-kernel copy between the file descriptor
and
. Either or both may be a socket.
was not opened for
reading or was not opened for writing.
[]
-or-
Descriptor is not valid or locked.
[]
The stream has been closed.
Unspecified error while reading from
.
[]
Non-blocking I/O has been selected using
and the
write would block.
[]
-or-
Insufficient memory to read from
.
[]
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.CLSCompliant(false)
System.Void
A specifying where to copy the
current stream contents to.
A containing the number of bytes to
copy from the current stream into .
Copies data from this stream to the specified
.
This performs an in-kernel copy between the file descriptor
and
. Either or both may be a socket.
was not opened for
reading or was not opened for writing.
[]
-or-
Descriptor is not valid or locked.
[]
The stream has been closed.
Unspecified error while reading from
.
[]
Non-blocking I/O has been selected using
and the
write would block.
[]
-or-
Insufficient memory to read from
.
[]
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.CLSCompliant(false)
System.Void
A containing the file descriptor to
copy the current stream contents to.
A containing the number of bytes to
copy from the current stream into .
Copies data from this stream to the specified file descriptor
.
This performs an in-kernel copy between the file descriptor
and
. Either or both may be a socket.
was not opened for
reading or was not opened for writing.
[]
-or-
Descriptor is not valid or locked.
[]
The stream has been closed.
Unspecified error while reading from
.
[]
Non-blocking I/O has been selected using
and the
write would block.
[]
-or-
Insufficient memory to read from
.
[]
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A containing the
user name to use for the new user-id and group-id.
Set the owner user ID and owner group ID of
.
The user is looked up in the local
password database and the resulting
and
are used as the new
owner user id and owner group id for
.
If this is called by the non-super user (usually the root
user), then the
and
bits
are cleared.
The effective user ID does not match the owner of the file and the
effective user ID is not the super-user.
[]
The stream has been closed.
A component of
that must exist does not exist.
[]
resides on a
read-only file system.
[]
-or-
An I/O error occurred while making the directory entry or
allocating the inode.
[]
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A containing the user
id of the new owner user. If -1, the owner user id is
unchanged.
A containing the
group id of the new owner group. If -1, the owner group id is
unchanged.
Set the owner user ID and owner group ID of
.
If this is called by the non-super user (usually the root
user), then the
and
bits
are cleared.
The effective user ID does not match the owner of the file and the
effective user ID is not the super-user.
[]
The stream has been closed.
A component of
that must exist does not exist.
[]
resides on a
read-only file system.
[]
-or-
An I/O error occurred while making the directory entry or
allocating the inode.
[]
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A containing the
user name of the owner user id to use.
A containing the
group name of the owner group id to use.
Set the owner user ID and owner group ID of
.
If this is called by the non-super user (usually the root
user), then the
and
bits
are cleared.
The effective user ID does not match the owner of the file and the
effective user ID is not the super-user.
[]
The stream has been closed.
A component of
that must exist does not exist.
[]
resides on a
read-only file system.
[]
-or-
An I/O error occurred while making the directory entry or
allocating the inode.
[]
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
2
The standard error file descriptor.
This is the value 2.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
0
The standard input file descriptor.
This is the value 0.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
1
The standard output file descriptor.
This is the value 1.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
To be added.
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A array containing the data to write.
The elements between and
are written to the stream.
A that specifies the zero-based byte
offset within at which to begin copying
bytes to the current stream.
A that specifies the maximum number of
bytes to be written to the current stream.
A specifying the byte offset within
the file to begin writing.
Writes a sequence of bytes to the current stream without
advancing the position within the stream.
Unlike , this method does
not modify .
Use the property to
determine whether the current instance supports writing.
is greater than the length of
.
is .
or is negative.
The stream does not support writing.
The stream has been closed.
There is no free space remaining on the file system
containing the file.
[]
-or-
An I/O error occurred while reading from or writing to the file system.
[]
-or-
An attempt was made to write over a disk label area at the beginning
of a slice.
Use disklabel(8) -W
to enable writing on the disk label area.
[]
-or-
The file descriptor is associated with a pipe, socket, or FIFO.
[]
An attempt is made to write to a pipe that is not open
for reading by any process.
[]
-or-
An attempt is made to write to a socket of type
that is not connected to a peer socket.
[]
-or-
An attempt was made to write a file that exceeds the process's
file size limit or the maximum file size.
[]
-or-
The user's quota of disk blocks on the file system
containing the file has been exhausted.
[]
-or-
A signal interrupted the write before it could be completed.
[]
-or-
The file was marked for non-blocking I/O,
and no data could be written immediately.
[]
-or-
The destination is no longer available when writing to a
UNIX
domain datagram socket on which
(2)
had been used to set a destination address.
[]
-or-
The mbuf pool has been completely exhausted when writing to a socket.
[]