51,409
社区成员
发帖
与我相关
我的任务
分享class FSDir {
...........
public FSDir(File dir) // 这里
throws IOException {
this.dir = dir;
this.children = null;
if (! dir.exists()) {
if (! dir.mkdirs()) {
throw new IOException("Mkdirs failed to create " +
dir.toString());
}
} else {
File[] files = dir.listFiles();
int numChildren = 0;
for (int idx = 0; idx < files.length; idx++) {
if (files[idx].isDirectory()) {
numChildren++;
} else if (Block.isBlockFilename(files[idx])) {
numBlocks++;
}
}
if (numChildren > 0) {
children = new FSDir[numChildren];
int curdir = 0;
for (int idx = 0; idx < files.length; idx++) {
if (files[idx].isDirectory()) {
children[curdir] = new FSDir(files[idx]); //这里 curdir++;
}
}
}
}
}