blob: 6764f78664702ac044ed893f221c4784b739cc62 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/* */ package NET.worlds.scape;
/* */
/* */ import java.io.File;
/* */ import java.io.FilenameFilter;
/* */ import java.util.Enumeration;
/* */ import java.util.StringTokenizer;
/* */ import java.util.Vector;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class FileList
/* */ implements FilenameFilter
/* */ {
/* */ private String dirList;
/* */ private String extList;
/* */ private Vector<String> exts;
/* */ private boolean keepPathInfo;
/* 25 */ private boolean sort = true;
/* */
/* */ public FileList(String dirList, String extList)
/* */ {
/* 29 */ this.dirList = dirList;
/* 30 */ this.extList = extList;
/* */ }
/* */
/* */ public String getExtList() {
/* 34 */ return this.extList;
/* */ }
/* */
/* */ private static Vector<String> breakUp(String list) {
/* 38 */ StringTokenizer t = new StringTokenizer(list, File.pathSeparator, false);
/* 39 */ Vector<String> v = new Vector();
/* 40 */ while (t.hasMoreTokens())
/* 41 */ v.addElement(t.nextToken());
/* 42 */ return v;
/* */ }
/* */
/* */ public boolean accept(File dir, String name) {
/* 46 */ return extMatches(name, this.exts);
/* */ }
/* */
/* */ public static boolean extMatches(String name, Vector<String> exts)
/* */ {
/* 51 */ int index = name.lastIndexOf(".");
/* 52 */ if (index != -1) {
/* 53 */ String ext = name.substring(index + 1);
/* 54 */ Enumeration<String> e = exts.elements();
/* 55 */ while (e.hasMoreElements())
/* 56 */ if (ext.equalsIgnoreCase((String)e.nextElement()))
/* 57 */ return true;
/* */ }
/* 59 */ return false;
/* */ }
/* */
/* */ public static boolean extMatches(String name, String exts) {
/* 63 */ return extMatches(name, breakUp(exts));
/* */ }
/* */
/* */ public boolean extMatches(String name)
/* */ {
/* 68 */ return extMatches(name, this.extList);
/* */ }
/* */
/* */ public FileList keepPathInfo() {
/* 72 */ this.keepPathInfo = true;
/* 73 */ return this;
/* */ }
/* */
/* */ public FileList dontSort() {
/* 77 */ this.sort = false;
/* 78 */ return this;
/* */ }
/* */
/* */
/* */
/* */
/* */ public static String removeTrailingSlash(String dir)
/* */ {
/* 86 */ if (dir != null) {
/* 87 */ int len = dir.length();
/* 88 */ if (len > 0) {
/* 89 */ char c = dir.charAt(len - 1);
/* 90 */ if ((c == '/') || (c == '\\')) {
/* 91 */ dir = dir.substring(0, len - 1);
/* */ }
/* */ }
/* */ }
/* 95 */ return dir;
/* */ }
/* */
/* */ public Vector<String> getList()
/* */ {
/* 100 */ this.exts = breakUp(this.extList);
/* 101 */ Vector<String> dirs = breakUp(this.dirList);
/* */
/* */
/* 104 */ Vector<String> v = new Vector();
/* 105 */ Enumeration<String> edirs = dirs.elements();
/* 106 */ while (edirs.hasMoreElements()) {
/* 107 */ String dir = removeTrailingSlash((String)edirs.nextElement());
/* */
/* 109 */ File f = new File(dir);
/* 110 */ if (f.exists()) {
/* 111 */ String[] list = f.list(this);
/* 112 */ if ((this.keepPathInfo) && (!dir.equals("."))) {
/* 113 */ dir = dir + File.separator;
/* */ } else
/* 115 */ dir = "";
/* 116 */ for (int i = 0; i < list.length; i++) {
/* 117 */ String name = dir + list[i];
/* 118 */ if (this.sort) {
/* 119 */ int count = v.size();
/* */
/* 121 */ String lname = name.toLowerCase();
/* 122 */ for (int j = 0; j < count; j++) {
/* 123 */ if (lname.compareTo(((String)v.elementAt(j))
/* 124 */ .toLowerCase()) < 0) {
/* 125 */ v.insertElementAt(name, j);
/* 126 */ break;
/* */ }
/* */ }
/* 129 */ if (j == count)
/* 130 */ v.addElement(name);
/* */ } else {
/* 132 */ v.addElement(name);
/* */ }
/* */ }
/* */ } }
/* 136 */ return v;
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\FileList.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|