|
@@ -229,15 +229,28 @@ public class RawLocalFileSystem extends FileSystem {
|
|
}
|
|
}
|
|
|
|
|
|
/** {@inheritDoc} */
|
|
/** {@inheritDoc} */
|
|
|
|
+ @Override
|
|
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize,
|
|
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize,
|
|
short replication, long blockSize, Progressable progress)
|
|
short replication, long blockSize, Progressable progress)
|
|
|
|
+ throws IOException {
|
|
|
|
+ return create(f, overwrite, true, bufferSize, replication, blockSize, progress);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private FSDataOutputStream create(Path f, boolean overwrite,
|
|
|
|
+ boolean createParent, int bufferSize,
|
|
|
|
+ short replication, long blockSize, Progressable progress)
|
|
throws IOException {
|
|
throws IOException {
|
|
if (exists(f) && !overwrite) {
|
|
if (exists(f) && !overwrite) {
|
|
throw new IOException("File already exists:"+f);
|
|
throw new IOException("File already exists:"+f);
|
|
}
|
|
}
|
|
Path parent = f.getParent();
|
|
Path parent = f.getParent();
|
|
- if (parent != null && !mkdirs(parent)) {
|
|
|
|
- throw new IOException("Mkdirs failed to create " + parent.toString());
|
|
|
|
|
|
+ if (parent != null) {
|
|
|
|
+ if (!createParent && !exists(parent)) {
|
|
|
|
+ throw new FileNotFoundException("Parent directory doesn't exist: "
|
|
|
|
+ + parent);
|
|
|
|
+ } else if (!mkdirs(parent)) {
|
|
|
|
+ throw new IOException("Mkdirs failed to create " + parent);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return new FSDataOutputStream(new BufferedOutputStream(
|
|
return new FSDataOutputStream(new BufferedOutputStream(
|
|
new LocalFSFileOutputStream(f, false), bufferSize), statistics);
|
|
new LocalFSFileOutputStream(f, false), bufferSize), statistics);
|
|
@@ -253,7 +266,19 @@ public class RawLocalFileSystem extends FileSystem {
|
|
setPermission(f, permission);
|
|
setPermission(f, permission);
|
|
return out;
|
|
return out;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /** {@inheritDoc} */
|
|
|
|
+ @Override
|
|
|
|
+ public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
|
|
|
|
+ boolean overwrite,
|
|
|
|
+ int bufferSize, short replication, long blockSize,
|
|
|
|
+ Progressable progress) throws IOException {
|
|
|
|
+ FSDataOutputStream out = create(f,
|
|
|
|
+ overwrite, false, bufferSize, replication, blockSize, progress);
|
|
|
|
+ setPermission(f, permission);
|
|
|
|
+ return out;
|
|
|
|
+ }
|
|
|
|
+
|
|
public boolean rename(Path src, Path dst) throws IOException {
|
|
public boolean rename(Path src, Path dst) throws IOException {
|
|
if (pathToFile(src).renameTo(pathToFile(dst))) {
|
|
if (pathToFile(src).renameTo(pathToFile(dst))) {
|
|
return true;
|
|
return true;
|