Author: lluis
Date: 2006-12-17 15:57:34 -0500 (Sun, 17 Dec 2006)
New Revision: 69631

Added:
   trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/
   
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/DefaultFileSystemExtension.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/FileSystemExtension.cs
Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Core/ChangeLog
Log:
* MonoDevelop.Core.FileSystem: Added missing files.

Modified: trunk/monodevelop/Core/src/MonoDevelop.Core/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Core/ChangeLog       2006-12-17 
19:47:34 UTC (rev 69630)
+++ trunk/monodevelop/Core/src/MonoDevelop.Core/ChangeLog       2006-12-17 
20:57:34 UTC (rev 69631)
@@ -1,5 +1,9 @@
 2006-12-17  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
+       * MonoDevelop.Core.FileSystem: Added missing files.
+
+2006-12-17  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
        * MonoDevelop.Core.AddIns/AddIn.cs,
          MonoDevelop.Core.AddIns.Setup/SetupService.cs: Track changes in
          FileService API.

Added: 
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/DefaultFileSystemExtension.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/DefaultFileSystemExtension.cs
       2006-12-17 19:47:34 UTC (rev 69630)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/DefaultFileSystemExtension.cs
       2006-12-17 20:57:34 UTC (rev 69631)
@@ -0,0 +1,83 @@
+
+using System;
+using System.IO;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Core.FileSystem
+{
+       public class DefaultFileSystemExtension: FileSystemExtension
+       {
+               public override bool CanHandlePath (string path, bool 
isDirectory)
+               {
+                       return true;
+               }
+               
+               public override void CopyFile (string source, string dest, bool 
overwrite)
+               {
+                       File.Copy (source, dest, overwrite);
+               }
+               
+               public override void RenameFile (string file, string newName)
+               {
+                       File.Move (file, newName);
+               }
+               
+               public override void MoveFile (string source, string dest)
+               {
+                       File.Move (source, dest);
+               }
+               
+               public override void DeleteFile (string file)
+               {
+                       File.Delete (file);
+               }
+               
+               public override void CreateDirectory (string path)
+               {
+                       Directory.CreateDirectory (path);
+               }
+               
+               public override void CopyDirectory (string sourcePath, string 
destPath)
+               {
+                       CopyDirectory (sourcePath, destPath, "");
+               }
+               
+               void CopyDirectory (string src, string dest, string subdir)
+               {
+                       string destDir = Path.Combine (dest, subdir);
+       
+                       if (!Directory.Exists (destDir))
+                               Runtime.FileService.CreateDirectory (destDir);
+       
+                       foreach (string file in Directory.GetFiles (src))
+                               Runtime.FileService.CopyFile (file, 
Path.Combine (destDir, Path.GetFileName (file)));
+       
+                       foreach (string dir in Directory.GetDirectories (src))
+                               CopyDirectory (dir, dest, Path.Combine (subdir, 
Path.GetFileName (dir)));
+               }
+               
+               public override void RenameDirectory (string path, string 
newName)
+               {
+                       Directory.Move (path, newName);
+               }
+               
+               public override void MoveDirectory (string source, string dest)
+               {
+                       Directory.Move (source, dest);
+               }
+               
+               public override void DeleteDirectory (string path)
+               {
+                       Directory.Delete (path, true);
+               }
+               
+               public override bool RequestFileEdit (string file)
+               {
+                       return true;
+               }
+               
+               public override void NotifyFileChanged (string file)
+               {
+               }
+       }
+}

Added: 
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/FileSystemExtension.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/FileSystemExtension.cs
      2006-12-17 19:47:34 UTC (rev 69630)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core.FileSystem/FileSystemExtension.cs
      2006-12-17 20:57:34 UTC (rev 69631)
@@ -0,0 +1,108 @@
+
+using System;
+using System.IO;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Core.FileSystem
+{
+       public abstract class FileSystemExtension
+       {
+               FileSystemExtension next;
+               
+               internal FileSystemExtension Next {
+                       get { return next; }
+                       set { next = value; }
+               }
+               
+               public abstract bool CanHandlePath (string path, bool 
isDirectory);
+               
+               FileSystemExtension GetNextForPath (string file, bool 
isDirectory)
+               {
+                       FileSystemExtension nx = next;
+                       while (nx != null && !nx.CanHandlePath (file, 
isDirectory))
+                               nx = nx.next;
+                       return nx;
+               }
+               
+               public virtual void CopyFile (string source, string dest, bool 
overwrite)
+               {
+                       GetNextForPath (dest, false).CopyFile (source, dest, 
overwrite);
+               }
+               
+               public virtual void RenameFile (string file, string newName)
+               {
+                       GetNextForPath (file, false).RenameFile (file, newName);
+               }
+               
+               public virtual void MoveFile (string source, string dest)
+               {
+                       GetNextForPath (source, false).MoveFile (source, dest);
+                       
+                       FileSystemExtension srcExt = GetNextForPath (source, 
false);
+                       FileSystemExtension dstExt = GetNextForPath (dest, 
false);
+                       
+                       if (srcExt == dstExt) {
+                               // Everything can be handled by the same file 
system
+                               srcExt.MoveFile (source, dest);
+                       } else {
+                               // If the file system of the source and dest 
files are
+                               // different, decompose the Move operation into 
a Copy
+                               // and Delete, so every file system can handle 
its part
+                               dstExt.CopyFile (source, dest, true);
+                               srcExt.DeleteFile (source);
+                       }
+               }
+               
+               public virtual void DeleteFile (string file)
+               {
+                       GetNextForPath (file, false).DeleteFile (file);
+               }
+               
+               public virtual void CreateDirectory (string path)
+               {
+                       GetNextForPath (path, true).CreateDirectory (path);
+               }
+               
+               public virtual void CopyDirectory (string sourcePath, string 
destPath)
+               {
+                       GetNextForPath (destPath, true).CopyDirectory 
(sourcePath, destPath);
+               }
+               
+               public virtual void RenameDirectory (string path, string 
newName)
+               {
+                       GetNextForPath (path, true).RenameDirectory (path, 
newName);
+               }
+               
+               public virtual void MoveDirectory (string sourcePath, string 
destPath)
+               {
+                       FileSystemExtension srcExt = GetNextForPath 
(sourcePath, true);
+                       FileSystemExtension dstExt = GetNextForPath (destPath, 
true);
+                       
+                       if (srcExt == dstExt) {
+                               // Everything can be handled by the same file 
system
+                               srcExt.MoveDirectory (sourcePath, destPath);
+                       } else {
+                               // If the file system of the source and dest 
files are
+                               // different, decompose the Move operation into 
a Copy
+                               // and Delete, so every file system can handle 
its part
+                               dstExt.CopyDirectory (sourcePath, destPath);
+                               srcExt.DeleteDirectory (sourcePath);
+                       }
+               }
+               
+               public virtual void DeleteDirectory (string path)
+               {
+                       GetNextForPath (path, true).DeleteDirectory (path);
+               }
+               
+               public virtual bool RequestFileEdit (string file)
+               {
+                       return GetNextForPath (file, false).RequestFileEdit 
(file);
+               }
+               
+               public virtual void NotifyFileChanged (string file)
+               {
+                       GetNextForPath (file, false).NotifyFileChanged (file);
+               }
+       }
+}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to