Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed problems with locking and changed other operations to be non-re…
…cursive.
- Loading branch information
sfred
committed
May 28, 2009
1 parent
84524a2
commit 17fdddc
Showing
5 changed files
with
49 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package fitnesse.revisioncontrol; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class FileUtils { | ||
public static final String CONTENT_FILE_NAME = "content.txt"; | ||
private static final String PROPERTIES_FILE_NAME = "properties.xml"; | ||
|
||
public static File[] getPathsFromRoot(File file, boolean recursive) { | ||
List<File> foundFiles = new ArrayList<File>(); | ||
|
||
if (file.isDirectory()) { | ||
getPathsInDirectory(file, foundFiles, recursive); | ||
} | ||
else | ||
foundFiles.add(file); | ||
|
||
return foundFiles.toArray(new File[foundFiles.size()]); | ||
} | ||
|
||
private static void getPathsInDirectory(File root, List<File> paths, boolean recursive) { | ||
for (File file : root.listFiles()) { | ||
if (file.getName().equals(".svn")) { | ||
continue; | ||
} | ||
|
||
if (file.isDirectory() && recursive) | ||
getPathsInDirectory(file, paths, recursive); | ||
else if (isContentOrPropertiesFile(file)) | ||
paths.add(file); | ||
} | ||
} | ||
|
||
private static boolean isContentOrPropertiesFile(File file) { | ||
return file.getName().endsWith(CONTENT_FILE_NAME) || file.getName().endsWith(PROPERTIES_FILE_NAME); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters