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
1010 * Unlike File.canWrite() or Files.isWritable() the directory does not need to
1111 * exist; it only needs a writable parent and the target needs to be
1212 * 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.
1613 */
1714fun Path.canCreateDirectory (): Boolean {
1815 var current: Path ? = this .toAbsolutePath()
1916 while (current != null && ! Files .exists(current)) {
2017 current = current.parent
2118 }
2219 // 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.
2523 return current != null && Files .isWritable(current) && Files .isDirectory(current)
2624}
You can’t perform that action at this time.
0 commit comments