[Mono-docs-list] path fix for provider.cs

John Luke jluke@cfl.rr.com
12 Jul 2003 02:17:02 -0400


--=-ap26kUaYMURrHJqcKwXD
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello,

Fix paths when running from other directory (like web-monodoc), and use
Path.Combine for (potential) Windows compatibility. Can I commit?

John

--=-ap26kUaYMURrHJqcKwXD
Content-Disposition: attachment; filename=pathfix.diff
Content-Type: text/x-patch; name=pathfix.diff; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/provider.cs,v
retrieving revision 1.34
diff -u -r1.34 provider.cs
--- provider.cs	11 Jul 2003 00:13:10 -0000	1.34
+++ provider.cs	12 Jul 2003 06:13:43 -0000
@@ -552,7 +552,8 @@
 		//
 		// Load the layout
 		//
-		doc.Load ("monodoc.xml");
+		string layout = Path.Combine (basedir, "monodoc.xml");
+		doc.Load (layout);
 		XmlNodeList nodes = doc.SelectNodes ("/node/node");
 
 		root.name_to_node ["root"] = root;
@@ -561,7 +562,7 @@
 		//
 		// Load the sources
 		//
-		string sources_dir = basedir + "/sources/";
+		string sources_dir = Path.Combine (basedir, "sources");
 		
 		string [] files = Directory.GetFiles (sources_dir);
 		foreach (string file in files){
@@ -601,10 +602,11 @@
 				string path = a.InnerText;
 
 				HelpSource hs = null;
+				string basefilepath = Path.Combine (sources_dir, basefile);
 				switch (provider){
 				case "ecma":
 					try {
-						hs = new EcmaHelpSource (sources_dir + basefile, false);
+						hs = new EcmaHelpSource (basefilepath, false);
 					} catch (FileNotFoundException) {
 						Console.Error.WriteLine ("Error: did not find one of the files in sources/"+basefile);
 						break;
@@ -612,7 +614,7 @@
 					break;
 				case "monohb":
 					try {
-						hs = new MonoHBHelpSource(sources_dir + basefile, false);
+						hs = new MonoHBHelpSource(basefilepath, false);
 					} catch (FileNotFoundException) {
 						Console.Error.WriteLine ("Error: did not find one of the files in sources/"+basefile);
 						break;
@@ -628,7 +630,7 @@
 					break;
 				case "simple":
 					try {
-						hs = new SimpleHelpSource (sources_dir + basefile, false);
+						hs = new SimpleHelpSource (basefilepath, false);
 					} catch (FileNotFoundException) {
 						Console.Error.WriteLine ("Error: did not find one of the files in sources/"+basefile);
 						break;

--=-ap26kUaYMURrHJqcKwXD--