On Thu, 2002-07-25 at 16:02, Paolo Molaro wrote:
> On 07/25/02 Erik Bagfors wrote:
> > For some reason I can't get bugzilla to mail me my password. It says it
> > does but I never get it. So I can't put this in bugzilla.
> [...]
> I filed it in bugzilla for you.
>
> > BTW, I saw that the attribute "Name" is missing in System.IO.FileStream
> > as well. That's real easy to fix. Will someone or should I send in a
> > patch?
>
> A patch + test case is always the best thing:-)
>
Ok, here you go. I don't have NUnit or whatever you are using for
testing. I guess I should install that for the future. So the test is
a separate application but I'm sure it's like 30 seconds of work for
someone who knows the testing-framework.
Warning I haven't tried this code since I was unable to recompile
corelib. But it's so easy it should just work :)
/Erik - who just got mono to use 100% CPU without wanting to die on kill
-9 :)
--
Erik B�gfors | [EMAIL PROTECTED]
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32
Index: FileStream.cs
===================================================================
RCS file: /mono/mcs/class/corlib/System.IO/FileStream.cs,v
retrieving revision 1.17
diff -u -r1.17 FileStream.cs
--- FileStream.cs 12 Jul 2002 15:58:59 -0000 1.17
+++ FileStream.cs 25 Jul 2002 19:56:58 -0000
@@ -60,6 +60,8 @@
if (name == "" || name.IndexOfAny (Path.InvalidPathChars) != -1)
throw new ArgumentException ();
+ this.name = name;
+
// TODO: demand permissions
this.handle = MonoIO.Open (name, mode, access, share);
@@ -95,6 +97,12 @@
}
}
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
public override long Length {
get { return MonoIO.GetLength (handle); }
}
@@ -333,6 +341,7 @@
private int buf_offset; // position of next byte
private bool buf_dirty; // true if buffer has been written to
private long buf_start; // location of buffer in file
+ private string name = "[Unknown]"; // name of file.
IntPtr handle; // handle to underlying file
}
using System;
using System.IO;
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
FileStream fs = new FileStream("/etc/passwd", FileMode.Open);
Console.WriteLine(fs.Name); // Should write the name of the file
IntPtr ip = fs.Handle;
FileStream fs2 = new FileStream (ip,FileAccess.Read);
Console.WriteLine(fs2.Name); // Should write [Unknown] (Like the
MS-version does)
}
}