01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.fixtures;
04:
05: import fit.RowFixture;
06: import java.io.File;
07:
08: public class FileSectionDirectoryListing extends RowFixture {
09:
10: public Object[] query() throws Exception {
11: File[] files = FileSection.getFileSection().listFiles();
12: Object[] fileWrappers = new Object[files.length];
13: for (int i = 0; i < files.length; i++) {
14: fileWrappers[i] = new FileWrapper(files[i]);
15: }
16: return fileWrappers;
17: }
18:
19: public Class getTargetClass() {
20: return FileWrapper.class;
21: }
22:
23: public class FileWrapper {
24: private File file;
25:
26: public FileWrapper(File file) {
27: this .file = file;
28: }
29:
30: public String path() {
31: int subStringLength = FileSection.getFileSection()
32: .getPath().length();
33: return file.getPath().substring(subStringLength + 1);
34: }
35: }
36: }
|