deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / Common / Files / Directory.sc
blobfa4d1afa654a369c0105fbbf46b054bcbb7209a7
1 /*
2         Not working,
3         but see String-pathMatch
4 */
5 /*
6 DirectoryEntry {
7         var <name, <pathName, <isDir=false, <isVisible;
10 Directory {
11         var <>pathName;
12         *new { arg pathName;
13                 ^super.new.pathName_(pathName);
14         }
16         numFiles {
17                 var numFiles = 0;
18                 this.scanFiles({ numFiles = numFiles + 1; });
19                 ^numFiles
20         }
21         at { arg index;
22                 ^this.prAt(DirectoryEntry.new, index);
23         }
25         scan { arg func;
26                 // scan all entries in this Directory
27                 var entry, index = 0;
28                 while ({
29                         entry = this.at(index);
30                         entry.notNil
31                 },{
32                         func.value(entry, index);
33                         index = index + 1;
34                 });
35         }
37         scanFiles { arg func;
38                 var index = 0;
39                 // scan only files in this Directory
40                 this.scan({ arg entry;
41                         if (entry.isDir.not and: { entry.isVisible }, {
42                                 func.value(entry, index);
43                                 index = index + 1;
44                         })
45                 });
46         }
48         deepScan { arg func;
49                 // recursively scan all files in and below this Directory
50                 this.scan({ arg entry;
51                         if (entry.isDir, {
52                                 Directory.new(entry.pathName).scanFiles(func);
53                         },{
54                                 func.value(entry);
55                         })
56                 });
57         }
59         // PRIVATE
60         prAt { arg entry, index;
61                 _Directory_At
62         }