コード例 #1
0
		public override object FindIcon(Uri path, string ext, string mimetype) {
			if(mimetype == null) {
				if(!path.IsFile) throw new ArgumentException();
				
				if(!fileMimeHash.ContainsKey(path.GetScrubbedLocalPath())) {
					ProcessStartInfo psi = new ProcessStartInfo("xdg-mime", string.Format("query filetype '{0}'", path.GetScrubbedLocalPath()));
					psi.RedirectStandardOutput = true;
					psi.UseShellExecute = false;
					Process p = Process.Start(psi);
					p.WaitForExit();
					StreamReader sr = p.StandardOutput;
					
					mimetype = sr.ReadLine();
					
					fileMimeHash[path.GetScrubbedLocalPath()] = mimetype;
				}
				else {
					mimetype = fileMimeHash[path.GetScrubbedLocalPath()];
				}
			}
			
			IconSet iconset = new IconSet();
			IconSource source = new IconSource();
			source.IconName = mimetype.Replace('/', '-'); //"inode-directory";
			//Console.WriteLine("{0}: {1}", psi.Arguments, text);
			iconset.AddSource(source);
			
			return iconset;
		}
コード例 #2
0
		public override XeFileInfo[] LoadDirectory(ref Uri uri) {
			if(!LoadsUriType(uri)) throw new ArgumentException();
			//System.Threading.Thread.Sleep(1000);
			DirectoryInfo di = new DirectoryInfo(uri.GetScrubbedLocalPath());
			Console.WriteLine("file://" + di.FullName.TrimEnd('\\', '/') + Path.DirectorySeparatorChar);
			uri = new Uri("file://" + di.FullName.TrimEnd('\\', '/') + Path.DirectorySeparatorChar);
			Console.WriteLine(uri.ToString());
			DirectoryInfo[] di2 = di.GetDirectories();
			FileInfo[] fi = di.GetFiles();
			int extra = ((bool)SettingsUtil.MainSettings["show..item"].data && di.Parent != null) ? 1 : 0;
			XeFileInfo[] fi2 = new XeFileInfo[di2.Length + fi.Length + extra];
			if(extra != 0) {
				fi2[0] = new XeFileInfo(di.Parent);
				fi2[0].Name = "..";
			}
			int i = extra;
			for(int j = 0; j < di2.Length; ++j, ++i) {
				try {
					fi2[i] = new XeFileInfo(di2[j]);
				}
				catch {

				}
			}
			for(int j = 0; j < fi.Length; ++j, ++i) {
				try {
					fi2[i] = new XeFileInfo(fi[j]);
				}
				catch {
					
				}
			}
			return (from fival in fi2 where fival != null select fival).ToArray();
		}
コード例 #3
0
		public override string ShortPath (Uri uri) {
			string txt = uri.GetScrubbedLocalPath();
			if(System.IO.Path.GetFileName(txt) == string.Empty) {
				string tmptxt = System.IO.Path.GetDirectoryName(txt);
				
				if(tmptxt == null) {
					return txt;
				}
				txt = tmptxt;
			}
			return System.IO.Path.GetFileName(txt);
		}
コード例 #4
0
		public override string DisplayPath (Uri uri) {
			return uri.GetScrubbedLocalPath();
		}
コード例 #5
0
		public override string[] FileName(Uri uri) {
			string path = uri.GetScrubbedLocalPath();
			return new string[] { Path.GetFileName(path), Path.GetFileNameWithoutExtension(path), Path.GetExtension(path) };
		}
コード例 #6
0
		public override Uri ParentDirectory(Uri uri) {
			return new Uri("file://" + Path.Combine(uri.GetScrubbedLocalPath(), ".."));
		}
コード例 #7
0
		public override Uri Combine(Uri uri, string addition) {
			return new Uri("file://" + Path.Combine(uri.GetScrubbedLocalPath(), addition));
		}
コード例 #8
0
		public override bool LoadsUriType(Uri uri) {
			return uri.IsFile && Directory.Exists(uri.GetScrubbedLocalPath());
		}
コード例 #9
0
		public override void Recycle(Uri uri) {
			switch(OS) {
				case PluginOSType.Unix:
					Send2Trash.Send2Trash.Put(uri.GetScrubbedLocalPath());
					break;
				
				default:
					throw new NotImplementedException();
			}
		}
コード例 #10
0
		public override void Delete(Uri uri) {
			string path = uri.GetScrubbedLocalPath();
			if(File.Exists(path)) {
				File.Delete(path);
			}
			else if(Directory.Exists(path)) {
				Directory.Delete(path, true);
			}
			else {
				throw new FileNotFoundException();
			}
		}
コード例 #11
0
		public override void Move(Uri src, Uri dest) {
			string src2 = src.GetScrubbedLocalPath();
			string dest2 = dest.GetScrubbedLocalPath();
			if(File.Exists(src2)) {
				if(Directory.Exists(dest2)) {
					dest2 = Path.Combine(dest2, Path.GetFileName(src2));
				}
				File.Move(src2, dest2);
			}
			else if(Directory.Exists(src2)) {
				try {
					Directory.Move(src2, dest2);
				}
				catch(IOException) {
					CopyDirectory(new DirectoryInfo(src2), new DirectoryInfo(dest2));
					Directory.Delete(src2, true);
				}
			}
		}
コード例 #12
0
		public override void Copy(Uri src, Uri dest) {
			string src2 = src.GetScrubbedLocalPath();
			string dest2 = dest.GetScrubbedLocalPath();
			if(File.Exists(src2)) {
				if(Directory.Exists(dest2)) {
					dest2 = Path.Combine(dest2, Path.GetFileName(src2));
				}
				File.Copy(src2, dest2);
			}
			else if(Directory.Exists(src2)) {
				CopyDirectory(new DirectoryInfo(src2), new DirectoryInfo(dest2));
			}
		}
コード例 #13
0
		public override void CreateDirectory(Uri path) {
			Directory.CreateDirectory(path.GetScrubbedLocalPath());
		}
コード例 #14
0
		public override void LoadFile(Uri path) {
			switch(OS) {
				case PluginOSType.Unix:
					Process.Start("xdg-open", string.Format("'{0}'", path.GetScrubbedLocalPath()));
					break;
				case PluginOSType.Windows:
					Process.Start(path.GetScrubbedLocalPath());
					break;
			}
		}
コード例 #15
0
		public override bool Exists(Uri uri) {
			return uri.IsFile && (File.Exists(uri.GetScrubbedLocalPath()) || Directory.Exists(uri.GetScrubbedLocalPath()));
		}