litesoft
Diff Revisions
64
vs
71
for /trunk/Java/core/Server/src/org/litesoft/util/DirectoryUtils.java
|
@@ -8,6 +8,7 @@ |
8 |
8 |
|
|
9 |
9 |
|
public class DirectoryUtils |
10 |
10 |
|
{ |
|
11 |
+ |
@SuppressWarnings({"UnusedDeclaration"}) |
11 |
12 |
|
public static File findDirectoryFromCurrent( String pSubPath ) |
12 |
13 |
|
{ |
13 |
14 |
|
return findDirectory( Utils.currentWorkingDirectory(), pSubPath ); |
|
@@ -65,6 +66,16 @@ |
65 |
66 |
|
return pPath.substring( Math.max( pPath.lastIndexOf( '/' ), pPath.lastIndexOf( '\\' ) ) + 1 ); |
66 |
67 |
|
} |
67 |
68 |
|
|
|
69 |
+ |
public static void checkDirectoryable( File pExpectedDir ) |
|
70 |
+ |
throws FileSystemException |
|
71 |
+ |
{ |
|
72 |
+ |
Utils.assertNotNull( "ExpectedDir", pExpectedDir ); |
|
73 |
+ |
if ( !pExpectedDir.isDirectory() && pExpectedDir.exists() ) |
|
74 |
+ |
{ |
|
75 |
+ |
throw new FileSystemException( "Exists, but is Not a Directory: " + pExpectedDir.getAbsolutePath() ); |
|
76 |
+ |
} |
|
77 |
+ |
} |
|
78 |
+ |
|
68 |
79 |
|
public static File insureDirectory( File pExpectedDir ) |
69 |
80 |
|
throws FileSystemException |
70 |
81 |
|
{ |
|
@@ -135,6 +146,7 @@ |
135 |
146 |
|
} |
136 |
147 |
|
} |
137 |
148 |
|
|
|
149 |
+ |
@SuppressWarnings({"UnusedDeclaration"}) |
138 |
150 |
|
public static void deleteAllEntries( File pDirectory ) |
139 |
151 |
|
throws FileSystemException |
140 |
152 |
|
{ |
|
@@ -169,6 +181,7 @@ |
169 |
181 |
|
* |
170 |
182 |
|
* @return error if not null or empty |
171 |
183 |
|
*/ |
|
184 |
+ |
@SuppressWarnings({"UnusedDeclaration"}) |
172 |
185 |
|
public static String compareDirs( String pExpectedDirectory, String pActualDirectory, String... pSkipEntries ) |
173 |
186 |
|
{ |
174 |
187 |
|
File expected = new File( pExpectedDirectory ); |
|
@@ -276,6 +289,28 @@ |
276 |
289 |
|
pSb.append( ", " ).append( pEntry ); |
277 |
290 |
|
} |
278 |
291 |
|
|
|
292 |
+ |
public static class DirsOnlyFilter implements FilenameFilter |
|
293 |
+ |
{ |
|
294 |
+ |
public static final FilenameFilter INSTANCE = new DirsOnlyFilter(); |
|
295 |
+ |
|
|
296 |
+ |
@Override |
|
297 |
+ |
public boolean accept( File dir, String name ) |
|
298 |
+ |
{ |
|
299 |
+ |
return new File( dir, name ).isDirectory(); |
|
300 |
+ |
} |
|
301 |
+ |
} |
|
302 |
+ |
|
|
303 |
+ |
public static class DirsOnlyFileFilter implements FileFilter |
|
304 |
+ |
{ |
|
305 |
+ |
public static final FileFilter INSTANCE = new DirsOnlyFileFilter(); |
|
306 |
+ |
|
|
307 |
+ |
@Override |
|
308 |
+ |
public boolean accept( File pathname ) |
|
309 |
+ |
{ |
|
310 |
+ |
return pathname.isDirectory(); |
|
311 |
+ |
} |
|
312 |
+ |
} |
|
313 |
+ |
|
279 |
314 |
|
public static class AllButFilter implements FilenameFilter |
280 |
315 |
|
{ |
281 |
316 |
|
private String[] mButs; |