Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorMichael Hutchinson <mhutchinson@novell.com>2011-02-11 22:21:02 +0300
committerMichael Hutchinson <mhutchinson@novell.com>2011-02-15 00:59:11 +0300
commit7727c4297d6efe43d1ef05ed80158b67e1e5b41f (patch)
treef65d86a8d9e61dd67d64f46240bd2dad7b27f37a /main/src
parent3ac8cc10bfec18faf8680c2b88811cb0e0ecf8fe (diff)
Fix user data locations
Put user data in the appropriate places for the OS and data type. Profiles are now also per MD version, but we migrate data from the previous version.
Diffstat (limited to 'main/src')
-rw-r--r--main/src/addins/CBinding/Parser/CTagsManager.cs6
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml4
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs4
-rw-r--r--main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs2
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml5
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs3
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs2
-rw-r--r--main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml4
-rwxr-xr-xmain/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor/XmlSchemaManager.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs16
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml4
-rw-r--r--main/src/addins/WelcomePage/WelcomePageView.cs10
-rw-r--r--main/src/core/MonoDevelop.Core/Makefile.am3
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigration.cs37
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigrationNode.cs77
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MonoTargetRuntimeFactory.cs2
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml10
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj3
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs33
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core/PropertyService.cs120
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs11
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataLocations.cs217
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataMigrationService.cs141
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Parser/ProjectDomService.cs5
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectService.cs2
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs60
-rw-r--r--main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs3
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateService.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs10
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ExternalTools/ExternalToolService.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs6
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs5
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs12
36 files changed, 754 insertions, 86 deletions
diff --git a/main/src/addins/CBinding/Parser/CTagsManager.cs b/main/src/addins/CBinding/Parser/CTagsManager.cs
index 0d47f845be..6449440e3c 100644
--- a/main/src/addins/CBinding/Parser/CTagsManager.cs
+++ b/main/src/addins/CBinding/Parser/CTagsManager.cs
@@ -41,7 +41,8 @@ namespace CBinding.Parser
public abstract Tag ParseTag (string tagEntry);
protected abstract IEnumerable<string> GetTags (FileInformation fileInfo);
protected abstract IEnumerable<string> GetTags (Project project, string filename, IEnumerable<string> headers);
- public static readonly string SystemTagsDirectory = Path.Combine (PropertyService.ConfigPath, "system-tags");
+
+ public static readonly string SystemTagsDirectory = PropertyService.Locations.Cache.Combine ("CTagsData");
public static string CTagsExecutable {
get { return PropertyService.Get<string> ("CBinding.CTagsExecutable", "ctags"); }
@@ -50,8 +51,7 @@ namespace CBinding.Parser
static CTagsManager ()
{
try {
- if (!Directory.Exists (SystemTagsDirectory))
- Directory.CreateDirectory (SystemTagsDirectory);
+ FileService.EnsureDirectoryExists (SystemTagsDirectory);
} catch (IOException ioe) {
LoggingService.LogError ("Error creating system tags directory", ioe);
}
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml
index 3ea841c774..bffa7d4399 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml
@@ -140,4 +140,8 @@
<Extension path = "/MonoDevelop/DesignerSupport/ToolboxProviders">
<Class class="MonoDevelop.DesignerSupport.Toolbox.CodeTemplateToolboxProvider" />
</Extension>
+
+ <Extension path = "/MonoDevelop/Core/UserDataMigration">
+ <Migration sourceVersion="2.4" kind="ConfigLocal" sourcePath="Toolbox.xml" />
+ </Extension>
</Addin>
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs
index 0fe41c5def..4109af758d 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs
@@ -75,7 +75,7 @@ namespace MonoDevelop.DesignerSupport
}
static string ToolboxConfigFile {
- get { return System.IO.Path.Combine (PropertyService.ConfigPath, "Toolbox.xml"); }
+ get { return PropertyService.Locations.ConfigLocal.Combine ("Toolbox.xml"); }
}
#region Extension loading
@@ -606,7 +606,7 @@ namespace MonoDevelop.DesignerSupport
List<ComponentIndexFile> files = new List<ComponentIndexFile> ();
static string ToolboxIndexFile {
- get { return Path.Combine (PropertyService.ConfigPath, "ToolboxIndex.xml"); }
+ get { return PropertyService.Locations.Cache.Combine ("ToolboxIndex.xml"); }
}
internal static ComponentIndex Load ()
diff --git a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs
index a665150176..b6b31a34a6 100644
--- a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs
+++ b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs
@@ -166,7 +166,7 @@ namespace MonoDevelop.RegexToolkit
static string LibraryLocation {
get {
- return System.IO.Path.Combine (PropertyService.ConfigPath, libraryFileName);
+ return PropertyService.Locations.Cache.Combine (libraryFileName);
}
}
const string Node = "RegexLibrary";
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml
index 928c4a5414..b8b1bcf88a 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml
@@ -181,4 +181,9 @@
<Font name ="MessageBubbles" _displayName="Message bubbles" default ="_DEFAULT_SANS"/>
<Font name ="LanguageTooltips" _displayName="Editor tooltips" default ="_DEFAULT_SANS"/>
</Extension>
+
+ <Extension path = "/MonoDevelop/Core/UserDataMigration">
+ <Migration sourceVersion="2.4" kind="Data" isDirectory="true" sourcePath="syntaxmodes"
+ targetPath="HighlightingSchemes" />
+ </Extension>
</Addin>
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs
index e9078bc8b1..f02bfc2824 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs
@@ -34,7 +34,8 @@ namespace MonoDevelop.SourceEditor
{
static class AutoSave
{
- static string autoSavePath = Path.Combine (PropertyService.Get<string> ("MonoDevelop.CodeCompletion.DataDirectory", String.Empty), "AutoSave");
+ //FIXME: is this path a good one? wouldn't it be better to put autosaves beside the files anyway?
+ static string autoSavePath = PropertyService.Locations.Cache.Combine ("AutoSave");
static AutoSave ()
{
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs
index 230b78cd95..7b2ba5eadf 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs
@@ -35,7 +35,7 @@ namespace MonoDevelop.SourceEditor
{
public static FilePath SyntaxModePath {
get {
- return PropertyService.ConfigPath.Combine ("syntaxmodes");
+ return PropertyService.DataPath.Combine ("HighlightingSchemes");
}
}
diff --git a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml
index 79fe2859cf..ee5c19ec0e 100644
--- a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml
+++ b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml
@@ -150,4 +150,8 @@
<Extension path = "/MonoDevelop/ProjectModel/Gui/MimeTypePolicyPanels">
<Panel id = "XmlFormatting" _label = "XML Format" mimeType="application/xml" class = "MonoDevelop.Xml.Formatting.XmlFormattingPolicyPanel" />
</Extension>
+
+ <Extension path = "/MonoDevelop/Core/UserDataMigration">
+ <Migration sourceVersion="2.4" kind="Data" isDirectory="true" sourcePath="schemas" targetPath="XmlSchemas" />
+ </Extension>
</Addin>
diff --git a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor/XmlSchemaManager.cs b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor/XmlSchemaManager.cs
index 8e9bd2b06e..2883716b1c 100755
--- a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor/XmlSchemaManager.cs
+++ b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor/XmlSchemaManager.cs
@@ -216,7 +216,7 @@ namespace MonoDevelop.XmlEditor
// Gets the folder where schemas are stored for an individual user.
static string UserSchemaFolder {
- get { return Path.Combine (PropertyService.ConfigPath, "schemas"); }
+ get { return PropertyService.Locations.Data.Combine ("schemas"); }
}
// FIXME: Should really pass schema info with the event.
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs
index aaadf6fa3e..1dadc4c1c9 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs
@@ -217,6 +217,13 @@ namespace MonoDevelop.VersionControl
}
}
+ static string CommitMessagesFile {
+ get {
+ return PropertyService.Locations.Cache.Combine ("version-control-commit-msg");
+
+ }
+ }
+
static Hashtable GetCommitComments ()
{
if (comments != null)
@@ -230,7 +237,7 @@ namespace MonoDevelop.VersionControl
return null;
};
- string file = Path.Combine (PropertyService.ConfigPath, "version-control-commit-msg");
+ string file = CommitMessagesFile;
if (File.Exists (file)) {
FileStream stream = null;
try {
@@ -295,15 +302,14 @@ namespace MonoDevelop.VersionControl
FileStream stream = null;
try {
- string file = Path.Combine (PropertyService.ConfigPath, "version-control-commit-msg");
+ FilePath file = CommitMessagesFile;
if (comments.Count == 0) {
if (File.Exists (file))
FileService.DeleteFile (file);
return;
}
- if (!Directory.Exists (PropertyService.ConfigPath))
- Directory.CreateDirectory (PropertyService.ConfigPath);
+ FileService.EnsureDirectoryExists (file.ParentDirectory);
stream = new FileStream (file, FileMode.Create, FileAccess.Write);
BinaryFormatter formatter = new BinaryFormatter ();
formatter.Serialize (stream, comments);
@@ -506,7 +512,7 @@ namespace MonoDevelop.VersionControl
static string ConfigFile {
get {
- return Path.Combine (PropertyService.ConfigPath, "VersionControl.config");
+ return PropertyService.Locations.Config.Combine ("VersionControl.config");
}
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
index abe8e772c8..f2e1a85ec7 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
@@ -311,4 +311,8 @@
<CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Paste" />
</Extension>
+ <Extension path = "/MonoDevelop/Core/UserDataMigration">
+ <Migration sourceVersion="2.4" kind="Cache" sourcePath="version-control-commit-msg" />
+ <Migration sourceVersion="2.4" kind="Config" sourcePath="VersionControl.config" />
+ </Extension>
</Addin>
diff --git a/main/src/addins/WelcomePage/WelcomePageView.cs b/main/src/addins/WelcomePage/WelcomePageView.cs
index 714a0e6f61..0bc58f0ba3 100644
--- a/main/src/addins/WelcomePage/WelcomePageView.cs
+++ b/main/src/addins/WelcomePage/WelcomePageView.cs
@@ -97,9 +97,15 @@ namespace MonoDevelop.WelcomePage
scroller.Show ();
}
+ static string NewsFile {
+ get {
+ return PropertyService.Locations.Cache.Combine ("WelcomePageNews.xml");
+ }
+ }
+
public XmlDocument GetUpdatedXmlDocument ()
{
- string localCachedNewsFile = System.IO.Path.Combine (PropertyService.ConfigPath, "news.xml");
+ string localCachedNewsFile = NewsFile;
Stream stream = Assembly.GetExecutingAssembly ().GetManifestResourceStream ("WelcomePageContent.xml");
XmlDocument contentDoc = new XmlDocument ();
@@ -131,7 +137,7 @@ namespace MonoDevelop.WelcomePage
LoggingService.LogInfo ("Updating Welcome Page from '{0}'.", netNewsXml);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (netNewsXml);
- string localCachedNewsFile = System.IO.Path.Combine (PropertyService.ConfigPath, "news.xml");
+ string localCachedNewsFile = NewsFile;
FileInfo localNewsXml = new FileInfo (localCachedNewsFile);
if (localNewsXml.Exists)
request.IfModifiedSince = localNewsXml.LastWriteTime;
diff --git a/main/src/core/MonoDevelop.Core/Makefile.am b/main/src/core/MonoDevelop.Core/Makefile.am
index d1fa6f93d6..25fde55e2e 100644
--- a/main/src/core/MonoDevelop.Core/Makefile.am
+++ b/main/src/core/MonoDevelop.Core/Makefile.am
@@ -14,6 +14,7 @@ FILES = \
MonoDevelop.Core.AddIns/PackageInstalledCondition.cs \
MonoDevelop.Core.AddIns/PlatformCondition.cs \
MonoDevelop.Core.AddIns/TargetFrameworkNode.cs \
+ MonoDevelop.Core.AddIns/UserDataMigrationNode.cs \
MonoDevelop.Core.Assemblies/AssemblyContext.cs \
MonoDevelop.Core.Assemblies/ComposedAssemblyContext.cs \
MonoDevelop.Core.Assemblies/CustomRuntimeExecutionModeSet.cs \
@@ -159,6 +160,8 @@ FILES = \
MonoDevelop.Core/PropertyService.cs \
MonoDevelop.Core/Runtime.cs \
MonoDevelop.Core/StringParserService.cs \
+ MonoDevelop.Core/UserDataLocations.cs \
+ MonoDevelop.Core/UserDataMigrationService.cs \
MonoDevelop.Core/UserException.cs \
MonoDevelop.Core/XmlReadHelper.cs \
MonoDevelop.Projects.CodeGeneration/BaseRefactorer.cs \
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigration.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigration.cs
new file mode 100644
index 0000000000..bb05a2e2a0
--- /dev/null
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigration.cs
@@ -0,0 +1,37 @@
+//
+// UserDataMigration.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2011 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace MonoDevelop.Core.AddIns
+{
+ public class UserDataMigration
+ {
+ public UserDataMigration ()
+ {
+ }
+ }
+}
+
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigrationNode.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigrationNode.cs
new file mode 100644
index 0000000000..f48feb022f
--- /dev/null
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/UserDataMigrationNode.cs
@@ -0,0 +1,77 @@
+//
+// UserDataMigrationNode.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2011 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using Mono.Addins;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Core.AddIns
+{
+ class UserDataMigrationNode: ExtensionNode
+ {
+ [NodeAttribute (Required=true)]
+ string sourceVersion;
+
+ [NodeAttribute (Required=true)]
+ string sourcePath;
+
+ [NodeAttribute ()]
+ string targetPath;
+
+ [NodeAttribute (Required=true)]
+ UserDataKind kind;
+
+ [NodeAttribute (Name="handler")]
+ string handlerTypeName;
+
+ public string SourceVersion {
+ get { return sourceVersion; }
+ }
+
+ public FilePath SourcePath {
+ get { return FileService.MakePathSeparatorsNative (sourcePath); }
+ }
+
+ public FilePath TargetPath {
+ get {
+ return FileService.MakePathSeparatorsNative (
+ string.IsNullOrEmpty (targetPath)? sourcePath : targetPath);
+ }
+ }
+
+ public UserDataKind Kind {
+ get { return kind; }
+ }
+
+ public IUserDataMigrationHandler GetHandler ()
+ {
+ if (string.IsNullOrEmpty (handlerTypeName))
+ return null;
+ return (IUserDataMigrationHandler) Activator.CreateInstance (Addin.GetType (handlerTypeName));
+ }
+ }
+}
+
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MonoTargetRuntimeFactory.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MonoTargetRuntimeFactory.cs
index dce873485c..beb57dd23f 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MonoTargetRuntimeFactory.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MonoTargetRuntimeFactory.cs
@@ -35,7 +35,7 @@ namespace MonoDevelop.Core.Assemblies
class MonoTargetRuntimeFactory: ITargetRuntimeFactory
{
static RuntimeCollection customRuntimes = new RuntimeCollection ();
- static string configFile = Path.Combine (PropertyService.ConfigPath, "mono-runtimes.xml");
+ static string configFile = Path.Combine (PropertyService.Locations.Config, "mono-runtimes.xml");
static string[] commonLinuxPrefixes = new string[] { "/usr", "/usr/local" };
static MonoTargetRuntimeFactory ()
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml
index febf9ed9af..52d676407b 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml
@@ -58,6 +58,11 @@
</ExtensionNode>
</ExtensionPoint>
+ <ExtensionPoint path = "/MonoDevelop/Core/UserDataMigration">
+ <Description>Defines data to be migrated from the previous version of MonoDevelop.</Description>
+ <ExtensionNode name="Migration" type="MonoDevelop.Core.AddIns.UserDataMigrationNode" />
+ </ExtensionPoint>
+
<ExtensionPoint path = "/MonoDevelop/ProjectModel/Ambiences" name = "Language ambiences">
<Description>Language ambiences. Specified classes must implement IAmbience.</Description>
<ExtensionNode name="Class" />
@@ -178,6 +183,11 @@
<ExecutionHandler id="Native"
class = "MonoDevelop.Core.Execution.NativePlatformExecutionHandler"/>
</Extension>
+
+ <Extension path = "/MonoDevelop/Core/UserDataMigration">
+ <Migration sourceVersion="2.4" kind="Config" sourcePath="mono-runtimes.xml" />
+ <Migration sourceVersion="2.4" kind="Data" sourcePath="DefaultPolicies.xml" targetPath="Policies/Default.mdpolicy.xml" />
+ </Extension>
<Extension path = "/MonoDevelop/Core/Applications">
<Application id = "build" class = "MonoDevelop.Projects.BuildTool" description = "Project build tool"/>
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
index f484bca31e..d75880aeaf 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
@@ -484,6 +484,9 @@
<Compile Include="MonoDevelop.Projects\ProjectItemEventArgs.cs" />
<Compile Include="MonoDevelop.Core.Assemblies\TargetFrameworkMoniker.cs" />
<Compile Include="MonoDevelop.Projects.Dom.Serialization\AttributeEntry.cs" />
+ <Compile Include="MonoDevelop.Core\UserDataLocations.cs" />
+ <Compile Include="MonoDevelop.Core\UserDataMigrationService.cs" />
+ <Compile Include="MonoDevelop.Core.AddIns\UserDataMigrationNode.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ChangeLog" />
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs
index 885b230692..531933014d 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs
@@ -36,6 +36,7 @@ using Mono.Addins;
using MonoDevelop.Core.FileSystem;
using System.Collections.Generic;
using System.Threading;
+using System.Linq;
namespace MonoDevelop.Core
{
@@ -350,7 +351,8 @@ namespace MonoDevelop.Core
// Atomic rename of a file. It does not fire events.
public static void SystemRename (string sourceFile, string destFile)
- {
+ {
+ //FIXME: use the atomic System.IO.File.Replace on NTFS
if (PropertyService.IsWindows) {
string wtmp = null;
if (File.Exists (destFile)) {
@@ -385,6 +387,35 @@ namespace MonoDevelop.Core
else {
Mono.Unix.Native.Syscall.rename (sourceFile, destFile);
}
+ }
+
+ /// <summary>
+ /// Removes the directory if it's empty.
+ /// </summary>
+ public static void RemoveDirectoryIfEmpty (string directory)
+ {
+ if (Directory.Exists (directory) && !Directory.EnumerateFiles (directory).Any ())
+ Directory.Delete (directory);
+ }
+
+ /// <summary>
+ /// Creates a directory if it does not already exist.
+ /// </summary>
+ public static void EnsureDirectoryExists (string directory)
+ {
+ if (!Directory.Exists (directory))
+ Directory.CreateDirectory (directory);
+ }
+
+ /// <summary>
+ /// Makes the path separators native.
+ /// </summary>
+ public static string MakePathSeparatorsNative (string path)
+ {
+ if (path == null || path.Length == 0)
+ return path;
+ char c = Path.DirectorySeparatorChar == '\\'? '/' : '\\';
+ return path.Replace (c, Path.DirectorySeparatorChar);
}
static bool HandleError (string message, Exception ex)
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/PropertyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/PropertyService.cs
index e493f27ded..2d00661582 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/PropertyService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/PropertyService.cs
@@ -31,11 +31,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
+using System.Runtime.InteropServices;
namespace MonoDevelop.Core
{
public static class PropertyService
{
+ const string CURRENT_PROFILE_VERSION = "2.6";
+
readonly static string FileName = "MonoDevelopProperties.xml";
static Properties properties;
@@ -54,13 +57,13 @@ namespace MonoDevelop.Core
}
}
- public static FilePath ConfigPath {
- get {
- string configPath = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
- return Path.Combine (configPath, "MonoDevelop");
- }
+ public static UserDataLocations Locations {
+ get; private set;
}
+ /// <summary>
+ /// Location of data files that are bundled with MonoDevelop itself.
+ /// </summary>
public static FilePath DataPath {
get {
string result = System.Configuration.ConfigurationManager.AppSettings ["DataDirectory"];
@@ -96,24 +99,107 @@ namespace MonoDevelop.Core
static PropertyService ()
{
Counters.PropertyServiceInitialization.BeginTiming ();
-
- IsWindows = Path.DirectorySeparatorChar == '\\';
-
- if (!LoadProperties (Path.Combine (ConfigPath, FileName))) {
- if (!LoadProperties (Path.Combine (DataPath, FileName))) {
- properties = new Properties ();
- properties.Set ("MonoDevelop.Core.FirstRun", true);
+
+ IsWindows = Path.DirectorySeparatorChar == '\\';
+ IsMac = !IsWindows && IsRunningOnMac ();
+
+ FilePath testProfileRoot = Environment.GetEnvironmentVariable ("MONODEVELOP_PROFILE");
+ if (!testProfileRoot.IsNullOrEmpty) {
+ Locations = UserDataLocations.ForTest (CURRENT_PROFILE_VERSION, testProfileRoot);
+ } else {
+ Locations = GetLocations (CURRENT_PROFILE_VERSION);
+ }
+
+ string migrateVersion = null;
+ UserDataLocations migratableProfile = null;
+
+ var prefsPath = Locations.Config.Combine (FileName);
+ if (!File.Exists (prefsPath)) {
+ if (GetMigratableProfile (testProfileRoot, out migratableProfile, out migrateVersion)) {
+ FilePath migratePrefsPath = migratableProfile.Config.Combine (FileName);
+ try {
+ var parentDir = prefsPath.ParentDirectory;
+ //can't use file service until property sevice in initialized
+ if (!Directory.Exists (parentDir))
+ Directory.CreateDirectory (parentDir);
+ File.Copy (migratePrefsPath, prefsPath);
+ LoggingService.LogInfo ("Migrated core properties from {0}", migratePrefsPath);
+ } catch (IOException ex) {
+ string message = string.Format ("Failed to migrate core properties from {0}", migratePrefsPath);
+ LoggingService.LogError (message, ex);
+ }
+ } else {
+ LoggingService.LogInfo ("Did not find previous version from which to migrate data");
}
}
+
+ if (!LoadProperties (prefsPath)) {
+ properties = new Properties ();
+ properties.Set ("MonoDevelop.Core.FirstRun", true);
+ }
+
+ if (migratableProfile != null)
+ UserDataMigrationService.SetMigrationSource (migratableProfile, migrateVersion);
+
properties.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args) {
if (PropertyChanged != null)
PropertyChanged (sender, args);
};
- IsMac = !IsWindows && IsRunningOnMac();
Counters.PropertyServiceInitialization.EndTiming ();
}
+ static UserDataLocations GetLocations (string profileVersion)
+ {
+ if (IsWindows)
+ return UserDataLocations.ForWindows (profileVersion);
+ else if (IsWindows)
+ return UserDataLocations.ForMac (profileVersion);
+ else
+ return UserDataLocations.ForUnix (profileVersion);
+ }
+
+ static bool GetMigratableProfile (FilePath testProfileRoot, out UserDataLocations profile, out string version)
+ {
+ profile = null;
+ version = null;
+
+ //TODO: check 2.6 when 2.8 is released, etc
+ string[] migratableVersions = { };
+
+ //test profiles only migrate from test profiles
+ if (!testProfileRoot.IsNullOrEmpty) {
+ for (int i = migratableVersions.Length -1; i >= 0; i--) {
+ var p = UserDataLocations.ForTest (migratableVersions[i], testProfileRoot);
+ if (File.Exists (p.Config.Combine (FileName))) {
+ profile = p;
+ version = migratableVersions[i];
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //try versioned profiles
+ for (int i = migratableVersions.Length -1; i >= 0; i--) {
+ var p = UserDataLocations.ForTest (migratableVersions[i], testProfileRoot);
+ if (File.Exists (p.Config.Combine (FileName))) {
+ profile = p;
+ version = migratableVersions[i];
+ return true;
+ }
+ }
+
+ //try the old unversioned MD <= 2.4 profile
+ var md24 = UserDataLocations.ForMD24 ();
+ if (File.Exists (md24.Config.Combine (FileName))) {
+ profile = md24;
+ version = "2.4";
+ return true;
+ }
+ return false;
+ }
+
static bool LoadProperties (string fileName)
{
properties = null;
@@ -137,12 +223,12 @@ namespace MonoDevelop.Core
return properties != null;
}
- public static void SaveProperties()
+ public static void SaveProperties ()
{
Debug.Assert (properties != null);
- if (!Directory.Exists (ConfigPath))
- Directory.CreateDirectory (ConfigPath);
- properties.Save (Path.Combine (ConfigPath, FileName));
+ var prefsPath = Locations.Config.Combine (FileName);
+ FileService.EnsureDirectoryExists (prefsPath.ParentDirectory);
+ properties.Save (prefsPath);
}
public static T Get<T> (string property, T defaultValue)
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs
index 536087c4bb..15970ae124 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs
@@ -67,7 +67,10 @@ namespace MonoDevelop.Core
try {
Counters.RuntimeInitialization.Trace ("Initializing Addin Manager");
- AddinManager.Initialize (MonoDevelop.Core.PropertyService.ConfigPath);
+ AddinManager.Initialize (
+ PropertyService.Locations.Config,
+ PropertyService.Locations.Addins,
+ PropertyService.Locations.Cache);
AddinManager.InitializeDefaultLocalizer (new DefaultAddinLocalizer ());
if (updateAddinRegistry)
@@ -75,6 +78,12 @@ namespace MonoDevelop.Core
setupService = new SetupService (AddinManager.Registry);
Counters.RuntimeInitialization.Trace ("Initialized Addin Manager");
+ //have to do this after the addin service is initialized
+ if (UserDataMigrationService.HasSource) {
+ Counters.RuntimeInitialization.Trace ("Migrating User Data from MD " + UserDataMigrationService.SourceVersion);
+ UserDataMigrationService.StartMigration ();
+ }
+
RegisterAddinRepositories ();
Counters.RuntimeInitialization.Trace ("Initializing Assembly Service");
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataLocations.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataLocations.cs
new file mode 100644
index 0000000000..a91b3037fe
--- /dev/null
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataLocations.cs
@@ -0,0 +1,217 @@
+//
+// UserDataLocations.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2011 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace MonoDevelop.Core
+{
+ public class UserDataLocations
+ {
+ const string APP_ID = "MonoDevelop";
+
+ /// <summary>Location for cached data that can be regenerated.</summary>
+ public FilePath Cache { get; private set; }
+
+ /// <summary>Location for current preferences/settings.</summary>
+ public FilePath Config { get; private set; }
+
+ /// <summary>Preferences/settings specific to the local machine.</summary>
+ public FilePath ConfigLocal { get; private set; }
+
+ /// <summary>Root location for data files created or modifiable by the user, such as templates, snippets and color schemes.</summary>
+ public FilePath Data { get; private set; }
+
+ /// <summary>Location for log files.</summary>
+ public FilePath Logs { get; private set; }
+
+ /// <summary>Location for addins installed by the user.</summary>
+ public FilePath Addins { get; private set; }
+
+ //TODO: clear out temp files at startup
+ /// <summary>Location for temporary files.</summary>
+ public FilePath Temp { get; private set; }
+
+ /// <summary>Gets a location by its ID.</summary>
+ internal FilePath GetLocation (UserDataKind kind)
+ {
+ switch (kind) {
+ case UserDataKind.Addins:
+ return Addins;
+ case UserDataKind.Cache:
+ return Cache;
+ case UserDataKind.Data:
+ return Data;
+ case UserDataKind.Logs:
+ return Logs;
+ case UserDataKind.Config:
+ return Config;
+ case UserDataKind.ConfigLocal:
+ return ConfigLocal;
+ case UserDataKind.Temp:
+ return Temp;
+ default:
+ throw new ArgumentException ("Unknown UserDataLocation:" + kind.ToString ());
+ }
+ }
+
+ /// <summary>
+ /// Creates locations in a specific folder, for testing.
+ /// </summary>
+ internal static UserDataLocations ForTest (string version, FilePath profileLocation)
+ {
+ string appId = APP_ID + "-" + version;
+ return new UserDataLocations () {
+ Cache = profileLocation.Combine (appId, "Cache"),
+ Data = profileLocation.Combine (appId, "Data"),
+ ConfigLocal = profileLocation.Combine (appId, "Config"),
+ Config = profileLocation.Combine (appId, "ConfigLocal"),
+ Logs = profileLocation.Combine (appId, "Logs"),
+ Addins = profileLocation.Combine (appId, "Addins"),
+ Temp = profileLocation.Combine (appId, "Temp"),
+ };
+ }
+
+ internal static UserDataLocations ForWindows (string version)
+ {
+ string appId = APP_ID + "-" + version;
+ FilePath local = Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData);
+ FilePath roaming = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
+ //FilePath localLow = GetKnownFolderPath (new Guid ("A520A1A4-1780-4FF6-BD18-167343C5AF16"));
+
+ local = local.Combine (appId);
+ roaming = roaming.Combine (appId);
+
+ return new UserDataLocations () {
+ Data = roaming,
+ Config = roaming.Combine ("Config"),
+ ConfigLocal = local.Combine ("Config"),
+ Addins = local.Combine ("Addins"),
+ Logs = local.Combine ("Logs"),
+ Cache = local.Combine ("Cache"),
+ Temp = local.Combine ("Temp"),
+ };
+ }
+
+ internal static UserDataLocations ForMac (string version)
+ {
+ string appId = APP_ID + "-" + version;
+ FilePath home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+ FilePath library = home.Combine ("Library");
+
+ FilePath data = library.Combine (appId);
+ FilePath preferences = library.Combine ("Preferences", appId);
+ FilePath cache = library.Combine ("Cache", appId);
+ FilePath logs = library.Combine ("Logs", appId);
+ FilePath appSupport = library.Combine ("Application Support", appId);
+
+ return new UserDataLocations () {
+ Cache = cache,
+ Data = data,
+ Config = preferences,
+ ConfigLocal = preferences,
+ Logs = logs,
+ Addins = appSupport.Combine ("Addins"),
+ Temp = cache.Combine ("Temp"),
+ };
+ }
+
+ internal static UserDataLocations ForUnix (string version)
+ {
+ FilePath home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+ FilePath xdgDataHome = Environment.GetEnvironmentVariable ("XDG_DATA_HOME");
+ if (xdgDataHome.IsNullOrEmpty)
+ xdgDataHome = home.Combine (".local", "share");
+ FilePath xdgConfigHome = Environment.GetEnvironmentVariable ("XDG_CONFIG_HOME");
+ if (xdgConfigHome.IsNullOrEmpty)
+ xdgConfigHome = home.Combine (".config");
+ FilePath xdgCacheHome = Environment.GetEnvironmentVariable ("XDG_CACHE_HOME");
+ if (xdgCacheHome.IsNullOrEmpty)
+ xdgCacheHome = home.Combine (".cache");
+
+ string appId = APP_ID + "-" + version;
+ FilePath data = xdgDataHome.Combine (appId);
+ FilePath config = xdgConfigHome.Combine (appId);
+ FilePath cache = xdgCacheHome.Combine (appId);
+
+ return new UserDataLocations () {
+ Data = data,
+ Addins = data.Combine ("Addins"),
+ Config = config,
+ ConfigLocal = config,
+ Cache = cache,
+ Temp = cache.Combine ("Temp"),
+ Logs = cache.Combine ("Logs"),
+ };
+ }
+
+ internal static UserDataLocations ForMD24 ()
+ {
+ FilePath appdata = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
+ var mdConfig = appdata.Combine ("MonoDevelop");
+ return new UserDataLocations () {
+ Data = mdConfig,
+ Config = mdConfig,
+ ConfigLocal = mdConfig,
+ Addins = mdConfig.Combine ("addins"),
+ Logs = mdConfig,
+ Cache = mdConfig,
+ //temp is not migratable
+ };
+ }
+ /*
+ static string GetKnownFolderPath (Guid knownFolderId)
+ {
+ var pathHandle = IntPtr.Zero;
+ try {
+ int hresult = SHGetKnownFolderPath (knownFolderId, 0, IntPtr.Zero, out pathHandle);
+ if (hresult >= 0)
+ return Marshal.PtrToStringAuto (pathHandle);
+ throw Marshal.GetExceptionForHR (hresult);
+ } finally {
+ if (pathHandle != IntPtr.Zero)
+ Marshal.FreeCoTaskMem (pathHandle);
+ }
+ }
+
+ [DllImport ("shell32.dll")]
+ static extern int SHGetKnownFolderPath ([MarshalAs (UnmanagedType.LPStruct)] Guid rfid,
+ uint dwFlags, IntPtr hToken, out IntPtr pszPath);
+ */
+ }
+
+ enum UserDataKind
+ {
+ Cache,
+ Config,
+ ConfigLocal,
+ Data,
+ Logs,
+ Addins,
+ Temp,
+ }
+}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataMigrationService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataMigrationService.cs
new file mode 100644
index 0000000000..7541a79956
--- /dev/null
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/UserDataMigrationService.cs
@@ -0,0 +1,141 @@
+//
+// UserDataMigrationService.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2011 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using Mono.Addins;
+using MonoDevelop.Core.AddIns;
+
+namespace MonoDevelop.Core
+{
+ static class UserDataMigrationService
+ {
+ static UserDataLocations profile;
+ static string version;
+ static bool handlerAdded;
+
+ //TODO: it would be nice to migrate custom addins that are installed after first run
+ //maybe we would maintain a property with IDs of migrated addins, and check that on addin load
+ //and if an unknown addin comes along, re-migrate just nodes of that addin
+ public static void SetMigrationSource (UserDataLocations profile, string version)
+ {
+ if (UserDataMigrationService.profile != null)
+ throw new InvalidOperationException ("Already set");
+ if (profile == null)
+ throw new ArgumentNullException ("profile");
+ if (version == null)
+ throw new ArgumentNullException ("version");
+
+ UserDataMigrationService.profile = profile;
+ UserDataMigrationService.version = version;
+ }
+
+ public static string SourceVersion {
+ get { return version; }
+ }
+
+ public static bool HasSource {
+ get { return version != null; }
+ }
+
+ public static void StartMigration ()
+ {
+ if (profile != null && !handlerAdded) {
+ AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Core/UserDataMigration", HandleUserDataMigration);
+ handlerAdded = true;
+ }
+ }
+
+ static void HandleUserDataMigration (object sender, ExtensionNodeEventArgs args)
+ {
+ if (args.Change != ExtensionChange.Add)
+ return;
+
+ var node = (UserDataMigrationNode) args.ExtensionNode;
+ if (node.SourceVersion != version)
+ return;
+
+ FilePath source = FilePath.Null;
+ FilePath target = FilePath.Null;
+
+ try {
+ source = profile.GetLocation (node.Kind).Combine (node.SourcePath);
+ target = PropertyService.Locations.GetLocation (node.Kind).Combine (node.TargetPath);
+
+ bool sourceIsDirectory = Directory.Exists (source);
+
+ if (sourceIsDirectory) {
+ if (Directory.Exists (target))
+ return;
+ } else {
+ if (File.Exists (target) || Directory.Exists (target) || !File.Exists (source))
+ return;
+ }
+
+ LoggingService.LogInfo ("Migrating '{0}' to '{1}'", source, target);
+ if (!sourceIsDirectory)
+ FileService.EnsureDirectoryExists (target.ParentDirectory);
+
+ var handler = node.GetHandler ();
+ if (handler != null) {
+ handler.Migrate (source, target);
+ return;
+ }
+
+ if (sourceIsDirectory) {
+ DirectoryCopy (source, target);
+ } else {
+ File.Copy (source, target);
+ }
+ } catch (Exception ex) {
+ string message = string.Format ("{0}: Failed to migrate '{1}' to '{2}'",
+ node.Addin.Id, source.ToString () ?? "", target.ToString () ?? "");
+ LoggingService.LogError (message, ex);
+ }
+ }
+
+ static void DirectoryCopy (FilePath source, FilePath target)
+ {
+ foreach (FilePath f in Directory.EnumerateFiles (source, "*", SearchOption.AllDirectories)) {
+ var rel = FileService.AbsoluteToRelativePath (source, f);
+ var t = target.Combine (rel);
+ var dir = t.ParentDirectory;
+ if (!Directory.Exists (dir))
+ Directory.CreateDirectory (dir);
+ File.Copy (f, t);
+ }
+ }
+ }
+
+ public interface IUserDataMigrationHandler
+ {
+ void Migrate (FilePath source, FilePath target);
+ }
+}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Parser/ProjectDomService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Parser/ProjectDomService.cs
index 329c81197e..eefffd57cc 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Parser/ProjectDomService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Parser/ProjectDomService.cs
@@ -196,9 +196,8 @@ namespace MonoDevelop.Projects.Dom.Parser
static string GetDefaultCompletionFileLocation ()
{
- string path = Path.Combine (PropertyService.ConfigPath, "CodeCompletionData");
- if (!Directory.Exists (path))
- Directory.CreateDirectory (path);
+ string path = Path.Combine (PropertyService.Locations.Cache, "CodeCompletionData");
+ FileService.EnsureDirectoryExists (path);
return path;
}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectService.cs
index 79dc94e080..cfa59cb0cd 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectService.cs
@@ -497,7 +497,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild
throw new InvalidOperationException ("Unknown MSBuild ToolsVersion '" + toolsVersion + "'");
}
- FilePath p = FilePath.Build (PropertyService.ConfigPath, "xbuild", toolsVersion, "MonoDevelop.Projects.Formats.MSBuild.exe");
+ FilePath p = FilePath.Build (PropertyService.Locations.Cache, "xbuild", toolsVersion, "MonoDevelop.Projects.Formats.MSBuild.exe");
if (!File.Exists (p) || File.GetLastWriteTime (p) < File.GetLastWriteTime (sourceExe)) {
if (!Directory.Exists (p.ParentDirectory))
Directory.CreateDirectory (p.ParentDirectory);
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs
index 625c094b1e..a8302ac111 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs
@@ -61,10 +61,7 @@ namespace MonoDevelop.Projects.Policies
{
AddinManager.AddExtensionNodeHandler (TYPE_EXT_POINT, HandlePolicyTypeUpdated);
AddinManager.AddExtensionNodeHandler (SET_EXT_POINT, HandlePolicySetUpdated);
- MonoDevelop.Core.Runtime.ShuttingDown += delegate {
- SaveDefaultPolicies ();
- };
- LoadDefaultPolicies ();
+ LoadPolicies ();
defaultPolicyBag.ReadOnly = true;
PolicySet pset = GetPolicySet ("Invariant");
@@ -930,9 +927,9 @@ namespace MonoDevelop.Projects.Policies
return null;
}
- static string DefaultPoliciesPath {
+ static FilePath PoliciesFolder {
get {
- return Path.Combine (PropertyService.ConfigPath, "DefaultPolicies.xml");
+ return Path.Combine (PropertyService.Locations.Data, "Policies");
}
}
@@ -1148,23 +1145,31 @@ namespace MonoDevelop.Projects.Policies
/// <summary>
- /// Saves the default policies.
+ /// Saves the policies.
/// </summary>
- public static void SaveDefaultPolicies ()
+ public static void SavePolicies ()
{
- ParanoidSave (DefaultPoliciesPath, "default policies", delegate (StreamWriter writer) {
- XmlWriterSettings xws = new XmlWriterSettings ();
- xws.Indent = true;
- XmlWriter xw = XmlTextWriter.Create(writer, xws);
+ SavePolicy (defaultPolicies);
+ foreach (PolicySet ps in userSets)
+ SavePolicy (ps);
+ }
+
+ static void SavePolicy (PolicySet set)
+ {
+ string file = PoliciesFolder.Combine (set.Name + ".mdpolicy.xml");
+ string friendlyName = string.Format ("policy '{0}'", set.Name);
+ ParanoidSave (file, friendlyName, delegate (StreamWriter writer) {
+ var xws = new XmlWriterSettings () {
+ Indent = true,
+ };
+ var xw = XmlTextWriter.Create (writer, xws);
xw.WriteStartElement ("Policies");
- defaultPolicies.SaveToXml (xw);
- foreach (PolicySet ps in userSets)
- ps.SaveToXml (xw);
+ set.SaveToXml (xw);
xw.WriteEndElement ();
});
- }
+ }
- static void LoadDefaultPolicies ()
+ static void LoadPolicies ()
{
if (defaultPolicies != null)
defaultPolicies.PolicyChanged -= DefaultPoliciesPolicyChanged;
@@ -1172,7 +1177,22 @@ namespace MonoDevelop.Projects.Policies
userSets.Clear ();
defaultPolicies = null;
- ParanoidLoad (DefaultPoliciesPath, "default policies", delegate (StreamReader reader) {
+ if (Directory.Exists (PoliciesFolder)) {
+ foreach (var file in Directory.GetFiles (PoliciesFolder, "*.mdpolicy.xml")) {
+ LoadPolicy (file);
+ }
+ }
+
+ if (defaultPolicies == null) {
+ defaultPolicies = new PolicySet ("Default", null);
+ }
+ defaultPolicies.PolicyChanged += DefaultPoliciesPolicyChanged;
+ }
+
+ static void LoadPolicy (FilePath file)
+ {
+ string friendlyName = string.Format ("policy file '{0}'", file.FileName);
+ ParanoidLoad (file, friendlyName, delegate (StreamReader reader) {
var xr = XmlReader.Create (reader);
xr.MoveToContent ();
if (xr.LocalName == "PolicySet") {
@@ -1194,10 +1214,6 @@ namespace MonoDevelop.Projects.Policies
}
}
});
- if (defaultPolicies == null) {
- defaultPolicies = new PolicySet ("Default", null);
- }
- defaultPolicies.PolicyChanged += DefaultPoliciesPolicyChanged;
}
static void DefaultPoliciesPolicyChanged (object sender, PolicyChangedEventArgs e)
diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml
index 67e203a66b..b33100a1e0 100644
--- a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml
+++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml
@@ -228,4 +228,13 @@
<Extension path = "/MonoDevelop/Ide/Fonts">
<Font name ="Editor" _displayName="Text Editor" default ="_DEFAULT_MONOSPACE"/>
</Extension>
+
+ <Extension path = "/MonoDevelop/Core/UserDataMigration">
+ <Migration sourceVersion="2.4" kind="Data" sourcePath="KeyBindings.xml" targetPath="KeyBindings/Custom.kb.xml" />
+ <Migration sourceVersion="2.4" kind="Data" sourcePath="KeyBindingsMac.xml" targetPath="KeyBindings/Custom.kb-mac.xml" />
+ <Migration sourceVersion="2.4" kind="Data" isDirectory="true" sourcePath="templates/code" targetPath="Snippets" />
+ <Migration sourceVersion="2.4" kind="Config" sourcePath="custom-command-modes.xml" />
+ <Migration sourceVersion="2.4" kind="Config" sourcePath="MonoDevelop-tools.xml" />
+ <Migration sourceVersion="2.4" kind="Config" sourcePath="EditingLayout2.xml" targetPath="EditingLayout.xml"/>
+ </Extension>
</Addin>
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs
index a698f7d97a..4df58d6d52 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs
@@ -63,7 +63,8 @@ namespace MonoDevelop.Components.Commands
static string ConfigFileName {
get {
- return Path.Combine (PropertyService.ConfigPath, PropertyService.IsMac? configFileNameMac : configFileName);
+ string file = PropertyService.IsMac? "Custom.kb.xml" : "Custom.mac-kb.xml";
+ return PropertyService.Locations.Config.Combine ("KeyBindings", file);
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateService.cs
index a2f245bad2..762a81c21b 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateService.cs
@@ -182,7 +182,7 @@ namespace MonoDevelop.Ide.CodeTemplates
static string TemplatePath {
get {
- return Path.Combine (PropertyService.ConfigPath, Path.Combine ("templates", "code"));
+ return Path.Combine (PropertyService.Locations.Data.Combine ("Snippets"));
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs
index f5fc0077c6..f89b5807c7 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs
@@ -52,6 +52,8 @@ namespace MonoDevelop.Ide.Commands
yield return new StringTagDescription ("EditorText", "Editor Text", false);
yield return new StringTagDescription ("StartupPath", "MonoDevelop Startup Directory", false);
yield return new StringTagDescription ("ConfigDir", "MonoDevelop Configuration Directory", false);
+ yield return new StringTagDescription ("DataDir", "MonoDevelop User Data Directory", false);
+ yield return new StringTagDescription ("LogDir", "MonoDevelop Log Directory", false);
}
public override object GetTagValue (Workbench wb, string tag)
@@ -106,7 +108,13 @@ namespace MonoDevelop.Ide.Commands
return AppDomain.CurrentDomain.BaseDirectory;
case "CONFIGDIR":
- return PropertyService.ConfigPath;
+ return PropertyService.Locations.Config;
+
+ case "DATADIR":
+ return PropertyService.Locations.Data;
+
+ case "LOGDIR":
+ return PropertyService.Locations.Logs;
}
throw new NotSupportedException ();
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
index 0c53a72576..6c5790cdaf 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
@@ -324,7 +324,7 @@ namespace MonoDevelop.Ide.Execution
if (globalModes == null) {
try {
XmlDataSerializer ser = new XmlDataSerializer (GetDataContext ());
- FilePath file = PropertyService.ConfigPath.Combine ("custom-command-modes.xml");
+ FilePath file = PropertyService.Locations.Config.Combine ("custom-command-modes.xml");
if (File.Exists (file))
globalModes = (CustomExecutionModes) ser.Deserialize (file, typeof(CustomExecutionModes));
} catch (Exception ex) {
@@ -343,7 +343,7 @@ namespace MonoDevelop.Ide.Execution
return;
try {
XmlDataSerializer ser = new XmlDataSerializer (GetDataContext ());
- FilePath file = PropertyService.ConfigPath.Combine ("custom-command-modes.xml");
+ FilePath file = PropertyService.Locations.Config.Combine ("custom-command-modes.xml");
ser.Serialize (file, globalModes, typeof(CustomExecutionModes));
} catch (Exception ex) {
LoggingService.LogError ("Could not save global custom execution modes.", ex);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ExternalTools/ExternalToolService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ExternalTools/ExternalToolService.cs
index 7bfd8929bb..3074d5de3e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ExternalTools/ExternalToolService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ExternalTools/ExternalToolService.cs
@@ -88,7 +88,7 @@ namespace MonoDevelop.Ide.ExternalTools
public static void SaveTools ()
{
- SaveTools (Path.Combine (PropertyService.ConfigPath, FileName));
+ SaveTools (PropertyService.Locations.Config.Combine (FileName));
}
static List<ExternalTool> LoadTools (string fileName)
@@ -120,7 +120,7 @@ namespace MonoDevelop.Ide.ExternalTools
static List<ExternalTool> LoadTools ()
{
- List<ExternalTool> result = LoadTools (Path.Combine (PropertyService.ConfigPath, FileName));
+ List<ExternalTool> result = LoadTools (PropertyService.Locations.Config.Combine (FileName));
if (result == null) {
LoggingService.LogInfo ("ExternalToolService: No user templates, reading default templates.");
result = LoadTools (Path.Combine (Path.Combine (PropertyService.DataPath, "options"), FileName));
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
index 90cd5a30a4..ddac68e8d3 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
@@ -57,7 +57,7 @@ namespace MonoDevelop.Ide.Gui
readonly static string toolbarsPath = "/MonoDevelop/Ide/Toolbar";
readonly static string stockLayoutsPath = "/MonoDevelop/Ide/WorkbenchLayouts";
- static string configFile = System.IO.Path.Combine (PropertyService.ConfigPath, "EditingLayout2.xml");
+ static string configFile = PropertyService.Locations.Config.Combine ("EditingLayout.xml");
const string fullViewModeTag = "[FullViewMode]";
const int MAX_LASTACTIVEWINDOWS = 10;
@@ -518,10 +518,10 @@ namespace MonoDevelop.Ide.Gui
}
}
- public Properties GetStoredMemento(IViewContent content)
+ public Properties GetStoredMemento (IViewContent content)
{
if (content != null && content.ContentName != null) {
- string directory = System.IO.Path.Combine (PropertyService.ConfigPath, "temp");
+ string directory = PropertyService.Locations.Cache.Combine ("temp");
if (!Directory.Exists(directory)) {
Directory.CreateDirectory(directory);
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
index 56bc1ba8a7..711b4c0d22 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
@@ -495,6 +495,7 @@ namespace MonoDevelop.Ide.Gui
if (MessageService.RunCustomDialog (ops, parentWindow) == (int) Gtk.ResponseType.Ok) {
PropertyService.SaveProperties ();
+ MonoDevelop.Projects.Policies.PolicyService.SavePolicies ();
}
} finally {
ops.Destroy ();
@@ -517,9 +518,7 @@ namespace MonoDevelop.Ide.Gui
if (panelId != null)
ops.SelectPanel (panelId);
- if (MessageService.RunCustomDialog (ops, parentWindow) == (int) Gtk.ResponseType.Ok) {
- MonoDevelop.Projects.Policies.PolicyService.SaveDefaultPolicies ();
- }
+ MessageService.RunCustomDialog (ops, parentWindow);
} finally {
ops.Destroy ();
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs
index e5ee3c4fe7..7f3e957732 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs
@@ -121,7 +121,7 @@ namespace MonoDevelop.Ide.Projects
foreach (PolicySet ps in usets)
PolicyService.RemoveUserPolicySet (ps);
- PolicyService.SaveDefaultPolicies ();
+ PolicyService.SavePolicies ();
}
void HandleDeleteButtonClicked (object sender, EventArgs e)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs
index aecb7941c0..31bdc2930f 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs
@@ -44,7 +44,7 @@ namespace MonoDevelop.Ide.Templates
base.Load (filenode, baseDirectory);
var srcAtt = filenode.Attributes["src"];
if (srcAtt != null) {
- contentSrcFile = MakePathNative (srcAtt.Value);
+ contentSrcFile = FileService.MakePathSeparatorsNative (srcAtt.Value);
if (contentSrcFile.IsNullOrEmpty)
throw new InvalidOperationException ("Template's Src attribute is empty");
contentSrcFile = contentSrcFile.ToAbsolute (baseDirectory);
@@ -53,14 +53,6 @@ namespace MonoDevelop.Ide.Templates
}
}
- static internal string MakePathNative (string path)
- {
- if (path == null || path.Length == 0)
- return path;
- char c = Path.DirectorySeparatorChar == '\\'? '/' : '\\';
- return path.Replace (c, Path.DirectorySeparatorChar);
- }
-
public override string CreateContent (string language)
{
return contentSrcFile.IsNullOrEmpty? content : File.ReadAllText (contentSrcFile);
@@ -78,7 +70,7 @@ namespace MonoDevelop.Ide.Templates
if (srcAtt == null)
throw new InvalidOperationException ("Template is missing Src attribute");
- contentSrcFile = TextFileDescriptionTemplate.MakePathNative (srcAtt.Value);
+ contentSrcFile = FileService.MakePathSeparatorsNative (srcAtt.Value);
if (contentSrcFile.IsNullOrEmpty)
throw new InvalidOperationException ("Template's Src attribute is empty");
contentSrcFile = contentSrcFile.ToAbsolute (baseDirectory);