Skip to content

Commit 5b531fc

Browse files
authored
Use AbsoluteUnixPath for LayerEntry (#1032)
1 parent 5446d45 commit 5b531fc

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

jib-core/src/main/java/com/google/cloud/tools/jib/image/LayerEntry.java

+1-20
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
package com.google.cloud.tools.jib.image;
1818

1919
import com.google.cloud.tools.jib.filesystem.AbsoluteUnixPath;
20-
import com.google.common.base.Preconditions;
2120
import java.nio.file.Path;
2221
import java.util.Objects;
23-
import java.util.StringJoiner;
2422

2523
/**
2624
* Represents an entry in the layer. A layer consists of many entries that can be converted into tar
@@ -36,23 +34,6 @@
3634
*/
3735
public class LayerEntry {
3836

39-
/**
40-
* Stringifies {@code path} in Unix form. The path must be absolute.
41-
*
42-
* @param path the path
43-
* @return the string form of the absolute path
44-
*/
45-
private static String toUnixPath(Path path) {
46-
Preconditions.checkArgument(
47-
path.getRoot() != null, "Tried to stringify a non-absolute path: %s", path);
48-
49-
StringJoiner pathJoiner = new StringJoiner("/", "/", "");
50-
for (Path pathComponent : path) {
51-
pathJoiner.add(pathComponent.toString());
52-
}
53-
return pathJoiner.toString();
54-
}
55-
5637
private final Path sourceFile;
5738
private final AbsoluteUnixPath extractionPath;
5839

@@ -108,7 +89,7 @@ public AbsoluteUnixPath getExtractionPath() {
10889
* @return the source file path
10990
*/
11091
public String getAbsoluteSourceFileString() {
111-
return toUnixPath(sourceFile.toAbsolutePath());
92+
return AbsoluteUnixPath.fromPath(sourceFile.toAbsolutePath()).toString();
11293
}
11394

11495
/**

0 commit comments

Comments
 (0)