PageRenderTime 83ms CodeModel.GetById 77ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/manostool/Environment.cs

http://github.com/jacksonh/manos
C# | 92 lines | 54 code | 15 blank | 23 comment | 9 complexity | 3da98f99b7b446ecc86a53d3bbfb1c6c MD5 | raw file
 1//
 2// Copyright (C) 2010 Jackson Harper (jackson@manosdemono.com)
 3//
 4// Permission is hereby granted, free of charge, to any person obtaining
 5// a copy of this software and associated documentation files (the
 6// "Software"), to deal in the Software without restriction, including
 7// without limitation the rights to use, copy, modify, merge, publish,
 8// distribute, sublicense, and/or sell copies of the Software, and to
 9// permit persons to whom the Software is furnished to do so, subject to
10// the following conditions:
11// 
12// The above copyright notice and this permission notice shall be
13// included in all copies or substantial portions of the Software.
14// 
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22//
23//
24
25
26using System;
27using System.IO;
28using System.Reflection;
29
30namespace Manos.Tool
31{
32
33
34	public class Environment
35	{
36
37		public Environment ()
38		{
39			LibDirectory = "lib";
40			TemplatesDirectory = "Templates";
41			WorkingDirectory = Directory.GetCurrentDirectory ();
42			
43			string exe_path = new Uri (typeof (Driver).Assembly.GetName ().CodeBase).LocalPath;
44
45			if (System.Environment.OSVersion.Platform == PlatformID.Win32NT
46				|| System.Environment.OSVersion.Platform == PlatformID.Win32S
47				|| System.Environment.OSVersion.Platform == PlatformID.Win32Windows
48				|| System.Environment.OSVersion.Platform == PlatformID.WinCE) {
49				ManosDirectory = Path.GetDirectoryName(exe_path);
50				DataDirectory = ManosDirectory;
51				DocsDirectory = Path.Combine(ManosDirectory, "docs");
52			} else {
53				ManosDirectory = Path.GetDirectoryName (exe_path);
54				string lib_dir = Path.GetDirectoryName (ManosDirectory);
55				string prefix = Path.GetDirectoryName (lib_dir);
56			
57				DataDirectory = Path.Combine (prefix, "share/manos/");
58				DocsDirectory = Path.Combine (prefix, "share/doc/manos");
59			}
60		}
61		
62		public string LibDirectory {
63			get;
64			set;
65		}
66		
67		public string ManosDirectory {
68			get;
69			set;
70		}
71		
72		public string TemplatesDirectory {
73			get;
74			set;
75		}
76		
77		public string WorkingDirectory {
78			get;
79			set;
80		}
81		
82		public string DataDirectory {
83			get;
84			set;
85		}
86
87		public string DocsDirectory {
88			get;
89			set;
90		}
91	}
92}