Changeset 719
- Timestamp:
- 07/29/07 03:20:40 (1 year ago)
- Files:
-
- other/dps/trunk/dsssps/dps.d (modified) (6 diffs)
- other/dps/trunk/dsssps/newfile.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
other/dps/trunk/dsssps/dps.d
r716 r719 13 13 import tango.sys.Process; 14 14 15 import tango.text.Util; 15 16 import tango.text.stream.LineIterator; 16 17 … … 38 39 // IDs for important elements 39 40 enum Elem { Tree, MenuBar, MenuPreferences, MenuQuit }; 41 42 /// Add a file list in a tree 43 void addFileList(wxTreeItemId top, char[][] flist, char[] prefix = "") 44 { 45 // first convert the file list to a list of directories and files in this dir 46 char[][][char[]] subdirs; 47 char[][] dirfiles; 48 49 // remove the prefix if applicable 50 if (prefix != "") { 51 Cout(prefix).newline; 52 flist = flist.dup; 53 foreach (k, f; flist) { 54 if (f.length >= prefix.length && 55 f[0 .. prefix.length] == prefix) { 56 flist[k] = f[prefix.length .. $]; 57 } 58 } 59 } 60 61 /// Subfunction to convert a path to the head and tail components 62 char[][] pathHeadTail(char[] p) 63 { 64 char[][] elems = split(p, "/"); 65 return [elems[0], join(elems[1..$], "/")]; 66 } 67 68 foreach (f; flist) { 69 FilePath fp = new FilePath(f); 70 if (fp.path() == "") { 71 // file in this dir 72 dirfiles ~= f; 73 } else { 74 auto pht = pathHeadTail(f); 75 subdirs[pht[0]] ~= pht[1]; 76 } 77 } 78 79 // Now, for each subdir, call recursively 80 foreach (sd; subdirs.keys.dup.sort) { 81 wxTreeItemId sdti = components.AppendItem(top, sd, 0); 82 addFileList(sdti, subdirs[sd]); 83 } 84 85 // Then, add the files 86 foreach (f; dirfiles.sort) { 87 components.AppendItem(top, f, 1, -1, new CompFile(f)); 88 } 89 } 40 90 41 91 /// Load the top dsss.conf file into the components tree … … 69 119 sect ~ " [" ~ conf.settings[sect]["type"] ~ "]", 0, -1, 70 120 new CompLibSect(sect)); 71 char[][] fs = targetToFiles(sect, conf); 72 foreach (f; fs) { 73 tree.AppendItem(comp, f, 1, -1, new CompFile(f)); 74 } 121 addFileList(comp, targetToFiles(sect, conf), sect ~ "/"); 75 122 76 123 // and add a button for adding new files … … 100 147 p.wait(); 101 148 102 // now sort the list 103 flist.sort; 104 // and add each item 105 foreach (file; flist) { 106 tree.AppendItem(comp, 107 file, 1, -1, 108 new CompFile(file)); 109 } 149 // now add the list 150 addFileList(comp, flist); 110 151 111 152 // then use rebuild to get the list of non-existing files … … 118 159 p.wait(); 119 160 120 // sort it 121 flist.sort; 161 // are there any non-existing files? 122 162 if (flist.length != 0) { 123 163 // OK, need to add a not-found section … … 125 165 tree.AppendItem(comp, 126 166 "Non-existent files", 0, -1); 127 128 foreach (file; flist) { 129 tree.AppendItem(notfound, 130 file, 1, -1, 131 new CompFileNew(file)); 132 } 167 addFileList(notfound, flist); 133 168 } 134 169 other/dps/trunk/dsssps/newfile.d
r713 r719 2 2 3 3 import tango.io.File; 4 import tango.io.FilePath; 4 5 5 6 import wx.wx; 7 8 import hcf.path; 6 9 7 10 import dsssps.dps; … … 50 53 } 51 54 55 // then make sure the directory exists 56 mkdirP((new FilePath(name)).path()); 57 52 58 // then fill out the basic file 53 59 (new File(name)).write("module " ~ mod ~ ";\n");
