Skip to content

Commit 15e94ed

Browse files
committed
Cleanup
1 parent 7ba61cb commit 15e94ed

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

core/apple/src/files/FileSystemApple.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@ internal actual val SystemTemporaryDirectoryImpl: Path
2626

2727
internal actual fun dirnameImpl(path: String): String {
2828
memScoped {
29-
return dirname(path.cstr.getPointer(this))?.toKString() ?: ""
29+
return dirname(path.cstr.ptr)?.toKString() ?: ""
3030
}
3131
}
3232

3333
internal actual fun basenameImpl(path: String): String {
3434
memScoped {
35-
return basename(path.cstr.getPointer(this))?.toKString() ?: ""
35+
return basename(path.cstr.ptr)?.toKString() ?: ""
3636
}
3737
}
3838

3939
internal actual fun isAbsoluteImpl(path: String): Boolean = path.startsWith('/')
4040

4141
internal actual fun mkdirImpl(path: String) {
42-
val mode: UShort = 511u
43-
if (mkdir(path, mode) != 0) {
42+
if (mkdir(path, PermissionAllowAll) != 0) {
4443
throw IOException("mkdir failed: ${strerror(errno)?.toKString()}")
4544
}
4645
}

core/linux/src/files/FileSystemLinux.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import platform.posix.dirname
1515
@OptIn(ExperimentalForeignApi::class)
1616
internal actual fun dirnameImpl(path: String): String {
1717
memScoped {
18-
return dirname(path.cstr.getPointer(this))?.toKString() ?: ""
18+
return dirname(path.cstr.ptr)?.toKString() ?: ""
1919
}
2020
}
2121

2222
@OptIn(ExperimentalForeignApi::class)
2323
internal actual fun basenameImpl(path: String): String {
2424
memScoped {
25-
return __xpg_basename(path.cstr.getPointer(this))?.toKString() ?: ""
25+
return __xpg_basename(path.cstr.ptr)?.toKString() ?: ""
2626
}
2727
}
2828

core/mingw/src/files/FileSystemMingw.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ internal actual fun atomicMoveImpl(source: Path, destination: Path) {
2424

2525
internal actual fun dirnameImpl(path: String): String {
2626
memScoped {
27-
return dirname(path.cstr.getPointer(this))?.toKString() ?: ""
27+
return dirname(path.cstr.ptr)?.toKString() ?: ""
2828
}
2929
}
3030

3131
internal actual fun basenameImpl(path: String): String {
3232
memScoped {
33-
return basename(path.cstr.getPointer(this))?.toKString() ?: ""
33+
return basename(path.cstr.ptr)?.toKString() ?: ""
3434
}
3535
}
3636

core/native/src/files/FileSystemNative.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,6 @@ internal expect fun mkdirImpl(path: String)
8181
public actual open class FileNotFoundException actual constructor(
8282
message: String?
8383
) : IOException(message)
84+
85+
// 777 in octal, rwx for all (owner, group and others).
86+
internal const val PermissionAllowAll: UShort = 511u

core/unix/src/files/FileSystemUnix.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ internal actual fun atomicMoveImpl(source: Path, destination: Path) {
2424
}
2525

2626
internal actual fun mkdirImpl(path: String) {
27-
val mode: UShort = 511u
28-
if (mkdir(path, mode.convert()) != 0) {
27+
if (mkdir(path, PermissionAllowAll.convert()) != 0) {
2928
throw IOException("mkdir failed: ${strerror(errno)?.toKString()}")
3029
}
3130
}

0 commit comments

Comments
 (0)