blob: 552b827a2555f960e6b1c5a3cb72918d9a804bce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.io;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;
/**
* Convenience class for calling FileSystem methods on a fixed Path.
*/
public class FileSystemPath {
private final FileSystem fileSystem;
private final Path path;
FileSystemPath(FileSystem fileSystem, Path path) {
this.fileSystem = fileSystem;
this.path = path;
}
public boolean isDirectory() {
return fileSystem.isDirectory(path);
}
public boolean isRegularFile() {
return fileSystem.isRegularFile(path);
}
public FileSystemPath createDirectory(FileAttribute<?>... attributes) {
fileSystem.createDirectory(path, attributes);
return this;
}
public String readUtf8File() {
return fileSystem.readUtf8File(path);
}
public FileSystemPath writeUtf8File(String content, OpenOption... options) {
fileSystem.writeUtf8File(path, content, options);
return this;
}
public Set<PosixFilePermission> getPermissions() {
return fileSystem.getPermissions(path);
}
public FileSystemPath setPermissions(String permissions) {
fileSystem.setPermissions(path, permissions);
return this;
}
public String getOwner() {
return fileSystem.getOwner(path);
}
public FileSystemPath setOwner(String owner) {
fileSystem.setOwner(path, owner);
return this;
}
public String getGroup() {
return fileSystem.getGroup(path);
}
public FileSystemPath setGroup(String group) {
fileSystem.setGroup(path, group);
return this;
}
}
|