File tree 2 files changed +6
-7
lines changed
compiler/src/dotty/tools/io 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ abstract class AbstractFile extends Iterable[AbstractFile] {
121
121
122
122
/** Does this abstract file denote an existing file? */
123
123
def exists : Boolean = {
124
- (jpath eq null ) || jpath.toFile. exists
124
+ (jpath eq null ) || Files . exists(jpath)
125
125
}
126
126
127
127
/** Does this abstract file represent something which can contain classfiles? */
Original file line number Diff line number Diff line change @@ -54,9 +54,8 @@ object Path {
54
54
55
55
def apply (path : String ): Path = apply(Paths .get(path))
56
56
def apply (jpath : JPath ): Path = try {
57
- val jfile = jpath.toFile
58
- if (jfile.isFile) new File (jpath)
59
- else if (jfile.isDirectory) new Directory (jpath)
57
+ if (Files .isRegularFile(jpath)) new File (jpath)
58
+ else if (Files .isDirectory(jpath)) new Directory (jpath)
60
59
else new Path (jpath)
61
60
} catch { case ex : SecurityException => new Path (jpath) }
62
61
@@ -161,10 +160,10 @@ class Path private[io] (val jpath: JPath) {
161
160
// Boolean tests
162
161
def canRead : Boolean = Files .isReadable(jpath)
163
162
def canWrite : Boolean = Files .isWritable(jpath)
164
- def exists : Boolean = try jpath.toFile. exists catch { case ex : SecurityException => false }
165
- def isFile : Boolean = try jpath.toFile.isFile catch { case ex : SecurityException => false }
163
+ def exists : Boolean = try Files . exists(jpath) catch { case ex : SecurityException => false }
164
+ def isFile : Boolean = try Files .isRegularFile(jpath) catch { case ex : SecurityException => false }
166
165
def isDirectory : Boolean =
167
- try jpath.toFile. isDirectory
166
+ try Files . isDirectory(jpath)
168
167
catch { case ex : SecurityException => jpath.toString == " ." }
169
168
def isAbsolute : Boolean = jpath.isAbsolute()
170
169
def isEmpty : Boolean = path.length == 0
You can’t perform that action at this time.
0 commit comments