diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2011-11-11 16:37:29 +0400 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2011-11-11 16:39:55 +0400 |
commit | 1d41d10382f051b81840d60d5720e479277c108e (patch) | |
tree | 125e1adcccb88edae842e7584fc59c9bf94bd2b3 /main/src/core | |
parent | e047f99f6df7b5c801102c03f903d4dd722b2989 (diff) |
[Core] Delete the existing file before copying the new one
It is possible (though unlikely) that the user can make files in
the bin folder readonly and so we should be sure to remove the
attribute and delete the file before copying over the new one.
Potential fix for bug #1625.
Diffstat (limited to 'main/src/core')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs | 11 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs index d1a591e12b..f767f9499d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs @@ -149,6 +149,17 @@ namespace MonoDevelop.Core foreach (string p in paths)
path = Path.Combine (path, p);
return new FilePath (path);
+ } + + public bool Delete () + { + if (!File.Exists (this)) + return false; + + var info = new FileInfo (this); + info.Attributes &= ~FileAttributes.ReadOnly; + info.Delete (); + return true; }
/// <summary> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index 62aabf796b..f367f4ae83 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -452,8 +452,8 @@ namespace MonoDevelop.Projects ProjectConfiguration config = (ProjectConfiguration) GetConfiguration (configuration); foreach (FileCopySet.Item item in GetSupportFileList (configuration)) { - string dest = Path.GetFullPath (Path.Combine (config.OutputDirectory, item.Target)); - string src = Path.GetFullPath (item.Src); + FilePath dest = Path.GetFullPath (Path.Combine (config.OutputDirectory, item.Target)); + FilePath src = Path.GetFullPath (item.Src); try { if (dest == src) @@ -466,6 +466,7 @@ namespace MonoDevelop.Projects FileService.CreateDirectory (Path.GetDirectoryName (dest)); if (File.Exists (src)) { + dest.Delete (); FileService.CopyFile (src, dest); // Copied files can't be read-only, so they can be removed when rebuilding the project |