1
// RecentFileItemSource.cs created with MonoDevelop
2
// User: dave at 2:18 PM 9/13/2007
4
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
8
using System.Collections.Generic;
13
namespace Do.PluginLib.Builtin
16
public class DirectoryFileItemSource : IItemSource
24
static DirectoryFileItemSource ()
26
Gnome.Vfs.Vfs.Initialize ();
29
public DirectoryFileItemSource (string path, int levels)
33
home = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
34
path = path.Replace ("~", home);
38
this.items = new List<IItem> ();
39
this.include_hidden = false;
47
public string Description {
48
get { return string.Format("Finds items in directory '{0}'", path); }
52
get { return "folder"; }
55
public ICollection<IItem> Items {
59
public bool UpdateItems ()
61
ReadItems (path, levels);
65
protected virtual void ReadItems (string dir, int levels)
71
if (levels == 0) return;
73
files = Directory.GetFiles (dir);
74
directories = Directory.GetDirectories (dir);
75
} catch (DirectoryNotFoundException) {
78
foreach (string file in files) {
79
if (!include_hidden && Path.GetFileName (file).StartsWith (".")) {
82
item = FileItem.Create (file);
85
foreach (string directory in directories) {
86
if (!include_hidden && Path.GetFileName (directory).StartsWith (".")) {
89
item = FileItem.Create (directory);
91
ReadItems (directory, levels - 1);