|
@@ -375,35 +375,38 @@ public class RawLocalFileSystem extends FileSystem {
|
|
|
if (!localf.exists()) {
|
|
|
throw new FileNotFoundException("File " + f + " does not exist");
|
|
|
}
|
|
|
- if (localf.isFile()) {
|
|
|
- if (!useDeprecatedFileStatus) {
|
|
|
- return new FileStatus[] { getFileStatus(f) };
|
|
|
- }
|
|
|
- return new FileStatus[] {
|
|
|
- new DeprecatedRawLocalFileStatus(localf, getDefaultBlockSize(f), this)};
|
|
|
- }
|
|
|
|
|
|
- String[] names = localf.list();
|
|
|
- if (names == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- results = new FileStatus[names.length];
|
|
|
- int j = 0;
|
|
|
- for (int i = 0; i < names.length; i++) {
|
|
|
- try {
|
|
|
- // Assemble the path using the Path 3 arg constructor to make sure
|
|
|
- // paths with colon are properly resolved on Linux
|
|
|
- results[j] = getFileStatus(new Path(f, new Path(null, null, names[i])));
|
|
|
- j++;
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- // ignore the files not found since the dir list may have have changed
|
|
|
- // since the names[] list was generated.
|
|
|
+ if (localf.isDirectory()) {
|
|
|
+ String[] names = localf.list();
|
|
|
+ if (names == null) {
|
|
|
+ return null;
|
|
|
}
|
|
|
+ results = new FileStatus[names.length];
|
|
|
+ int j = 0;
|
|
|
+ for (int i = 0; i < names.length; i++) {
|
|
|
+ try {
|
|
|
+ // Assemble the path using the Path 3 arg constructor to make sure
|
|
|
+ // paths with colon are properly resolved on Linux
|
|
|
+ results[j] = getFileStatus(new Path(f, new Path(null, null,
|
|
|
+ names[i])));
|
|
|
+ j++;
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ // ignore the files not found since the dir list may have have
|
|
|
+ // changed since the names[] list was generated.
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (j == names.length) {
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+ return Arrays.copyOf(results, j);
|
|
|
}
|
|
|
- if (j == names.length) {
|
|
|
- return results;
|
|
|
+
|
|
|
+ if (!useDeprecatedFileStatus) {
|
|
|
+ return new FileStatus[] { getFileStatus(f) };
|
|
|
}
|
|
|
- return Arrays.copyOf(results, j);
|
|
|
+ return new FileStatus[] {
|
|
|
+ new DeprecatedRawLocalFileStatus(localf,
|
|
|
+ getDefaultBlockSize(f), this) };
|
|
|
}
|
|
|
|
|
|
protected boolean mkOneDir(File p2f) throws IOException {
|