File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
src/main/kotlin/com/coder/gateway/sdk Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,15 @@ import java.nio.file.Path
10
10
* Unlike File.canWrite() or Files.isWritable() the directory does not need to
11
11
* exist; it only needs a writable parent and the target needs to be
12
12
* non-existent or a directory (not a regular file or nested under one).
13
- *
14
- * This check is deficient on Windows since directories that have write
15
- * permissions but are read-only will still return true.
16
13
*/
17
14
fun Path.canCreateDirectory (): Boolean {
18
15
var current: Path ? = this .toAbsolutePath()
19
16
while (current != null && ! Files .exists(current)) {
20
17
current = current.parent
21
18
}
22
19
// On Windows File.canWrite() only checks read-only while Files.isWritable()
23
- // also checks permissions. For directories neither of them seem to care if
24
- // it is read-only.
20
+ // also checks permissions so use the latter. Both only check read-only on
21
+ // files, not directories; on Windows you are allowed to create files inside
22
+ // read-only directories.
25
23
return current != null && Files .isWritable(current) && Files .isDirectory(current)
26
24
}
You can’t perform that action at this time.
0 commit comments