dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/IO DirectoryInfo.cs,N


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/IO DirectoryInfo.cs,NONE,1.1 FileAttributes.cs,NONE,1.1 FileInfo.cs,NONE,1.1FileSystemInfo.cs,NONE,1.1
Date: Fri, 31 Jan 2003 21:04:52 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/IO
In directory subversions:/tmp/cvs-serv30377/runtime/System/IO

Added Files:
        DirectoryInfo.cs FileAttributes.cs FileInfo.cs 
        FileSystemInfo.cs 
Log Message:


Add some non-ECMA classes that are required by SharpDevelop.


--- NEW FILE ---
/*
 * DirectoryInfo.cs - Implementation of the "System.IO.DirectoryInfo" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.IO
{

#if !ECMA_COMPAT

using System;

[Serializable]
public sealed class DirectoryInfo : FileSystemInfo
{
        // Constructor.
        public DirectoryInfo(String path)
                        {
                                if(path == null)
                                {
                                        throw new ArgumentNullException("path");
                                }
                                else if(path.IndexOfAny(Path.InvalidPathChars) 
!= -1)
                                {
                                        throw new ArgumentException
                                                (_("IO_InvalidPathname"), 
"path");
                                }
                                OriginalPath = path;
                                FullPath = Path.GetFullPath(path);
                        }

        // Properties.
        public DirectoryInfo Parent
                        {
                                get
                                {
                                        return new 
DirectoryInfo(Path.GetDirectoryName(FullPath));
                                }
                        }
        [TODO]
        public override bool Exists
                        {
                                get
                                {
                                        // TODO - make sure that the path is a 
directory.
                                        return File.Exists(FullPath);
                                }
                        }
        public override String Name
                        {
                                get
                                {
                                        return Path.GetFileName(FullPath);
                                }
                        }
        public DirectoryInfo Root
                        {
                                get
                                {
                                        return new 
DirectoryInfo(Path.GetPathRoot(FullPath));
                                }
                        }

        // Create a directory.
        [TODO]
        public void Create()
                        {
                                // TODO
                                // Directory.Create(FullPath);
                        }
        [TODO]
        public DirectoryInfo CreateSubdirectory(String name)
                        {
                                String dir = Path.Combine(FullPath, 
Path.GetFileName(name));
                                // TODO
                                // Directory.Create(dir);
                                return new DirectoryInfo(dir);
                        }

        // Delete the directory represented by this object.
        public override void Delete()
                        {
                                Directory.Delete(FullPath, false);
                        }
        public void Delete(bool recurse)
                        {
                                Directory.Delete(FullPath, recurse);
                        }

        // Move this directory to a new location.
        public void MoveTo(String dest)
                        {
                                Directory.Move(FullPath, dest);
                        }

        // Get the contents of this directory.
        public FileInfo[] GetFiles()
                        {
                                return GetFiles("*");
                        }
        [TODO]
        public FileInfo[] GetFiles(String pattern)
                        {
                                // TODO
                                return null;
                        }
        public DirectoryInfo[] GetDirectories()
                        {
                                return GetDirectories("*");
                        }
        [TODO]
        public DirectoryInfo[] GetDirectories(String pattern)
                        {
                                // TODO
                                return null;
                        }
        public FileSystemInfo[] GetFileSystemInfos()
                        {
                                return GetFileSystemInfos("*");
                        }
        [TODO]
        public FileSystemInfo[] GetFileSystemInfos(String pattern)
                        {
                                // TODO
                                return null;
                        }

        // Convert this object into a string.
        public override String ToString()
                        {
                                return OriginalPath;
                        }

}; // class FileInfo

#endif // !ECMA_COMPAT

}; // namespace System.IO

--- NEW FILE ---
/*
 * FileAttributes.cs - Implementation of the "System.IO.FileAttributes" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.IO
{

#if !ECMA_COMPAT

using System;

public enum FileAttributes
{
        ReadOnly                        = 0x00001,
        Hidden                          = 0x00002,
        System                          = 0x00004,
        Directory                       = 0x00010,
        Archive                         = 0x00020,
        Device                          = 0x00040,
        Normal                          = 0x00080,
        Temporary                       = 0x00100,
        SparseFile                      = 0x00200,
        ReparsePoint            = 0x00400,
        Compressed                      = 0x00800,
        Offline                         = 0x01000,
        NotContentIndexed       = 0x02000,
        Encrypted                       = 0x04000

}; // enum FileAttributes

#endif // !ECMA_COMPAT

}; // namespace System.IO

--- NEW FILE ---
/*
 * FileInfo.cs - Implementation of the "System.IO.FileInfo" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.IO
{

#if !ECMA_COMPAT

using System;

[Serializable]
public sealed class FileInfo : FileSystemInfo
{
        // Constructor.
        public FileInfo(String path)
                        {
                                if(path == null)
                                {
                                        throw new ArgumentNullException("path");
                                }
                                else if(path.IndexOfAny(Path.InvalidPathChars) 
!= -1)
                                {
                                        throw new ArgumentException
                                                (_("IO_InvalidPathname"), 
"path");
                                }
                                OriginalPath = path;
                                FullPath = Path.GetFullPath(path);
                        }

        // Properties.
        public String DirectoryName
                        {
                                get
                                {
                                        return Path.GetDirectoryName(FullPath);
                                }
                        }
        public DirectoryInfo Directory
                        {
                                get
                                {
                                        return new DirectoryInfo(DirectoryName);
                                }
                        }
        [TODO]
        public override bool Exists
                        {
                                get
                                {
                                        // TODO - make sure that the path is 
not a directory.
                                        return File.Exists(FullPath);
                                }
                        }
        [TODO]
        public long Length
                        {
                                get
                                {
                                        // TODO
                                        return 0;
                                }
                        }
        public override String Name
                        {
                                get
                                {
                                        return Path.GetFileName(FullPath);
                                }
                        }

        // Delete the file represented by this object.
        public override void Delete()
                        {
                                if(Exists)
                                {
                                        File.Delete(FullPath);
                                }
                        }

        // Open the file as a text stream.
        public StreamReader OpenText()
                        {
                                return new StreamReader(Open(FileMode.Open, 
FileAccess.Read));
                        }
        public StreamWriter CreateText()
                        {
                                return new StreamWriter
                                        (Open(FileMode.Create, 
FileAccess.Write));
                        }
        public StreamWriter AppendText()
                        {
                                return new StreamWriter
                                        (Open(FileMode.Append, 
FileAccess.Write));
                        }

        // Open the file as a binary stream.
        public FileStream Create()
                        {
                                return File.Create(FullPath);
                        }
        public FileStream OpenRead()
                        {
                                return Open(FileMode.Open, FileAccess.Read);
                        }
        public FileStream OpenWrite()
                        {
                                return Open(FileMode.OpenOrCreate, 
FileAccess.Write);
                        }
        public FileStream Open(FileMode mode)
                        {
                                return Open(mode, FileAccess.ReadWrite);
                        }
        public FileStream Open(FileMode mode, FileAccess access)
                        {
                                return Open(mode, access, FileShare.None);
                        }
        public FileStream Open(FileMode mode, FileAccess access, FileShare 
share)
                        {
                                return new FileStream(FullPath, mode, access, 
share);
                        }

        // Move or copy this file.
        public void MoveTo(String dest)
                        {
                                File.Move(FullPath, dest);
                        }
        public FileInfo CopyTo(String path)
                        {
                                return CopyTo(path, false);
                        }
        public FileInfo CopyTo(String path, bool overwrite)
                        {
                                String fullPath = Path.GetFullPath(path);
                                File.Copy(FullPath, fullPath);
                                return new FileInfo(fullPath);
                        }

        // Convert this object into a string.
        public override String ToString()
                        {
                                return OriginalPath;
                        }

}; // class FileInfo

#endif // !ECMA_COMPAT

}; // namespace System.IO

--- NEW FILE ---
/*
 * FileSystemInfo.cs - Implementation of the "System.IO.FileSystemInfo" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.IO
{

#if !ECMA_COMPAT

using System;

[Serializable]
public abstract class FileSystemInfo : MarshalByRefObject
{
        // Internal state.
        protected String FullPath;
        protected String OriginalPath;

        // Constructor.
        protected FileSystemInfo()
                        {
                                FullPath = null;
                                OriginalPath = null;
                        }

        // Properties.
        [TODO]
        public FileAttributes Attributes
                        {
                                get
                                {
                                        // TODO
                                        return 0;
                                }
                                set
                                {
                                        // TODO
                                }
                        }
        public DateTime CreationTime
                        {
                                get
                                {
                                        return File.GetCreationTime(FullPath);
                                }
                                set
                                {
                                        File.SetCreationTime(FullPath, value);
                                }
                        }
        public abstract bool Exists { get; }
        public String Extension
                        {
                                get
                                {
                                        return Path.GetExtension(Name);
                                }
                        }
        public virtual String FullName
                        {
                                get
                                {
                                        return FullPath;
                                }
                        }
        public DateTime LastAccessTime
                        {
                                get
                                {
                                        return File.GetLastAccessTime(FullPath);
                                }
                                set
                                {
                                        File.SetLastAccessTime(FullPath, value);
                                }
                        }
        public DateTime LastWriteTime
                        {
                                get
                                {
                                        return File.GetLastWriteTime(FullPath);
                                }
                                set
                                {
                                        File.SetLastWriteTime(FullPath, value);
                                }
                        }
        public abstract String Name { get; }

        // Delete the file represented by this object.
        public abstract void Delete();

        // Refresh the cache state information.
        public void Refresh()
                        {
                                // Nothing to do here - we don't cache values.
                        }

}; // class FileSystemInfo

#endif // !ECMA_COMPAT

}; // namespace System.IO





reply via email to

[Prev in Thread] Current Thread [Next in Thread]