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 the FILE
type.
is used for reading and
writing files on a file system and interoperating with the standard
ANSI/ISO C FILE pointer data type.
objects support
random access to files using the
method, and the
properties of
instances
encapsulating files are set to .
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;
class Directory {
public static void Main(String[] args) {
StdioFileStream fs = new StdioFileStream ("log.txt", "ab");
StreamWriter w = new StreamWriter(fs);
Log ("Test1", w);
Log ("Test2", w);
w.Close(); // Close the writer and underlying file.
fs = new StdioFileStream("log.txt", "rb");
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 pointer.
Creates a type,
wrapping the existing unmanaged FILE pointer
.
By default, is owned by the
created instance.
is an invalid FILE pointer.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing the file name to open.
Opens for reading.
or is
.
is a 0-length string.
could not be opened.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing a FILE pointer
A specifying whether or not the created
instance "owns"
.
Creates a type,
wrapping the existing unmanaged FILE pointer
.
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 an invalid FILE pointer.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing a FILE pointer
A value
that determins how the file may be accessed by the
object. This parameter is
used to specify the initial values of the
and
properties.
Creates a type,
wrapping the existing unmanaged FILE pointer
with the specified file
.
By default, is owned by the
created instance.
is an invalid FILE pointer.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing the file name to open.
A value
that determins how the file may be accessed by the
object. This parameter is
used to specify the initial values of the
and
properties.
Opens with the specified file access
.
or is
.
is a 0-length string.
could not be opened.
is not one of
,
, or
.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing the file name to open.
A value that
determines how to open or create the file.
Opens with the specified file mode
.
or is
.
is a 0-length string.
could not be opened.
exists and
was specified.
doesn't exist and
was specified.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing the file name to open.
A specifying how to access .
Opens with the specified
.
The argument points to a string
beginning with one of the following sequences (Additional characters
may follow these sequences.):
Description
-
"r"
Open text file for reading. The stream is positioned at the beginning of the file.
-
"r+"
Open for reading and writing. The stream is positioned at the beginning of the file.
-
"w"
Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file.
-
"w+"
Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file.
-
"a"
Open for writing. The file is created if it does not exist. The stream is positioned at the end of the file. Subsequent writes to the file will always end up at the then current end of file, irrespective of any intervening call or similar.
-
"a+"
Open for reading and writing. The file is created if it does not exist. The stream is positioned at the end of the file. Subsequent writes to the file will always end up at the then current end of file, irrespective of any intervening or similar.
The string can also include the letter
"b" either as a third character or as a character between the
characters in any of the two-character strings described above, and
is used to enable binary reading/writing on platforms which
have different text/binary encodings (read: Microsoft Windows). The
default (non-b) is text encoding.
Any created files will have mode S_IRUSR | S_IWUSR | S_IRGRP |
S_IWGRP | S_IROTH | S_IWOTH (0666), as modified by the process'
umask value (see (2)).
ANSI C requires that a file positioning function intervene
between output and input, unless an input operation encounters
end-of-file.
or is
.
is a 0-length string.
could not be opened.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing a FILE pointer
A value
that determins how the file may be accessed by the
object. This parameter is
used to specify the initial values of the
and
properties.
A specifying whether or not the created
instance "owns"
.
Creates a type,
wrapping the existing unmanaged FILE pointer
with the specified file
.
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 an invalid FILE pointer.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A containing the file name to open.
A value that
determines how to open or create the file.
A value
that determins how the file may be accessed by the
object. This parameter is
used to specify the initial values of the
and
properties.
Opens with the specified file mode
and file access
.
or is
.
is a 0-length string.
could not be opened.
exists and
was specified.
doesn't exist and
was specified.
is not one of
,
, or
.
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.
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.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.IntPtr
The underlying FILE pointer.
A containing the underlying
FILE pointer.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.IntPtr
An invalid FILE pointer.
This is .
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.Int64
To be added.
To be added.
To be added.
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.Void
A from which to
restore the file position.
Set the current file position saved in a
instance.
The type holds
a platform-specific representation of a file position. This is useful
when the underlying standard C library cannot hold a file position in
a long data type. For example, on 32-bit platforms a
long is usually 32-bits in size; thus valid file
positions as used from
cannot be set past 2^31 bytes (effectively limiting you to 2GB files).
Use this member if your underlying platform doesn't support
ing within large files, or you
need to save text stream information.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
Set
to the beginning of the file.
This is equivalent to (0,
);
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A in which to save
the current file position.
Save the current file position into a
instance.
The type holds
a platform-specific representation of a file position. This is useful
when the underlying standard C library cannot hold a file position in
a long data type. For example, on 32-bit platforms a
long is usually 32-bits in size; thus valid file
positions as used from
cannot be set past 2^31 bytes (effectively limiting you to 2GB files).
Use this member if your underlying platform doesn't support
ing within large files, or you
need to save text stream information.
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
To be added.
To be added.
To be added.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.IntPtr
The standard error file stream.
This is the
global variable.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.IntPtr
The standard input file stream.
This is the
global variable.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.IntPtr
The standard output file stream.
This is the
global variable.
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.