Skip to content

Commit

Permalink
Change mkdir default POSIX permissions from 777 to 775 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Dec 20, 2023
1 parent 2ebddbf commit d7ff664
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal actual external fun fs_exists(path: String): Boolean

/** [docs](https://nodejs.org/api/fs.html#fsmkdirsyncpath-options) */
@JsName("mkdirSync")
internal external fun fs_mkdirSync(path: String): String?
internal external fun fs_mkdirSync(path: String, options: Options.Mkdir): String?

/** [docs](https://nodejs.org/api/fs.html#fsreadfilesyncpath-options) */
@JsName("readFileSync")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal actual fun fs_remove(path: String): Boolean {

internal actual fun fs_mkdir(path: String): Boolean {
return try {
fs_mkdirSync(path)
fs_mkdirSync(path, Options.Mkdir())
true
} catch (_: Throwable) {
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ package io.matthewnelson.kmp.file.internal

internal sealed class Options {

internal class Mkdir private constructor(
internal val recursive: Boolean,
internal val mode: String,
): Options() {
// modifies the default directory permissions used from 777 to 775
internal constructor(): this(false, "775")
}

internal class ReadDir private constructor(
internal val encoding: String?,
internal val withFileTypes: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal actual fun fs_realpath(path: String): String {

internal actual fun fs_platform_mkdir(
path: String,
): Int = fs_platform_mkdir(path, Mode("777").toModeT())
): Int = fs_platform_mkdir(path, Mode("775").toModeT())

@Suppress("NOTHING_TO_INLINE")
internal expect inline fun fs_platform_chmod(
Expand Down

0 comments on commit d7ff664

Please sign in to comment.