using System;

namespace DM2AE
{
	// 
	public class OSPath
	{
		// 
		string s = "";

		// 
		public OSPath()
		{

		}
		// 
		public OSPath(string s)
		{
			this.s = s;
		}

		// 
		public OSPath GetDir()
		{
			int i = s.LastIndexOf('\\');
			if (i != -1)
				return new OSPath(s.Substring(0, i + 1));
			return new OSPath();
		}
		// 
		public string GetFileName()
		{
			int i = s.LastIndexOf('\\');
			if (i != 1)
				return s.Substring(i + 1);
			return s;
		}

		// 
		static public OSPath GetNeighborFilePath(string sFile)
		{
			return new OSPath(joinPath(System.AppDomain.CurrentDomain.BaseDirectory, sFile));
		}

		// 
		static string joinPath(string sDir, string sFile)
		{
			if (sDir.LastIndexOf('\\') != sDir.Length - 1)
				return sDir + '\\' + sFile;
			return sDir + sFile;
		}

		// 
		static public OSPath operator +(OSPath p, string s)
		{
			return new OSPath(p.s + s);
		}
		// 
		static public OSPath operator &(OSPath p, string s)
		{
			return new OSPath(joinPath(p.s, s));
		}
		// 
		static public implicit operator string(OSPath p)
		{
			return p.s;
		}
	}
}
