mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8307976: (fs) Files.createDirectories(dir) returns dir::toAbsolutePath instead of dir
Reviewed-by: alanb
This commit is contained in:
parent
f57c78337e
commit
6d4782bc73
2 changed files with 14 additions and 7 deletions
|
@ -758,14 +758,15 @@ public final class Files {
|
|||
// parent may not exist or other reason
|
||||
}
|
||||
SecurityException se = null;
|
||||
Path absDir = dir;
|
||||
try {
|
||||
dir = dir.toAbsolutePath();
|
||||
absDir = dir.toAbsolutePath();
|
||||
} catch (SecurityException x) {
|
||||
// don't have permission to get absolute path
|
||||
se = x;
|
||||
}
|
||||
// find a descendant that exists
|
||||
Path parent = dir.getParent();
|
||||
Path parent = absDir.getParent();
|
||||
while (parent != null) {
|
||||
try {
|
||||
provider(parent).checkAccess(parent);
|
||||
|
@ -778,7 +779,7 @@ public final class Files {
|
|||
if (parent == null) {
|
||||
// unable to find existing parent
|
||||
if (se == null) {
|
||||
throw new FileSystemException(dir.toString(), null,
|
||||
throw new FileSystemException(absDir.toString(), null,
|
||||
"Unable to determine if root directory exists");
|
||||
} else {
|
||||
throw se;
|
||||
|
@ -787,7 +788,7 @@ public final class Files {
|
|||
|
||||
// create directories
|
||||
Path child = parent;
|
||||
for (Path name: parent.relativize(dir)) {
|
||||
for (Path name: parent.relativize(absDir)) {
|
||||
child = child.resolve(name);
|
||||
createAndCheckIsDirectory(child, attrs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue