File tree Expand file tree Collapse file tree 5 files changed +47
-62
lines changed
build-logic/src/main/kotlin/kotlinx/io/conventions Expand file tree Collapse file tree 5 files changed +47
-62
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ kotlin {
80
80
group(" androidNative" )
81
81
}
82
82
}
83
+
84
+ group(" nonAndroid" ) {
85
+ group(" apple" )
86
+ group(" mingw" )
87
+ group(" linux" )
88
+ }
83
89
}
84
90
group(" nodeFilesystemShared" ) {
85
91
withJs()
Original file line number Diff line number Diff line change @@ -53,26 +53,6 @@ internal actual fun realpathImpl(path: String): String {
53
53
}
54
54
}
55
55
56
-
57
- @OptIn(ExperimentalForeignApi ::class , ExperimentalStdlibApi ::class )
58
- internal actual class OpaqueDirEntry constructor(private val dir : CPointer <DIR >) : AutoCloseable {
59
- actual fun readdir (): String? {
60
- val entry = readdir(dir) ? : return null
61
- return entry[0 ].d_name.toKString()
62
- }
63
-
64
- override fun close () {
65
- closedir(dir)
66
- }
67
- }
68
-
69
- @OptIn(ExperimentalForeignApi ::class )
70
- internal actual fun opendir (path : String ): OpaqueDirEntry {
71
- val dirent = platform.posix.opendir(path)
72
- if (dirent != null ) return OpaqueDirEntry (dirent)
73
- throw IOException (" Can't open directory $path : ${strerror(errno)?.toKString() ? : " reason unknown" } " )
74
- }
75
-
76
56
internal actual fun metadataOrNullImpl (path : Path ): FileMetadata ? {
77
57
val attributes = NSFileManager .defaultManager().fileAttributesAtPath(path.path, traverseLink = true ) ? : return null
78
58
val fileType = attributes[NSFileType ] as String
Original file line number Diff line number Diff line change 5
5
6
6
package kotlinx.io.files
7
7
8
- import kotlinx.cinterop.*
9
- import kotlinx.io.IOException
10
- import platform.posix.*
8
+ import kotlinx.cinterop.ExperimentalForeignApi
9
+ import kotlinx.cinterop.cstr
10
+ import kotlinx.cinterop.memScoped
11
+ import kotlinx.cinterop.toKString
12
+ import platform.posix.__xpg_basename
13
+ import platform.posix.dirname
11
14
12
15
@OptIn(ExperimentalForeignApi ::class )
13
16
internal actual fun dirnameImpl (path : String ): String {
@@ -27,22 +30,3 @@ internal actual fun basenameImpl(path: String): String {
27
30
}
28
31
29
32
internal actual fun isAbsoluteImpl (path : String ): Boolean = path.startsWith(' /' )
30
-
31
- @OptIn(ExperimentalForeignApi ::class , ExperimentalStdlibApi ::class )
32
- internal actual class OpaqueDirEntry constructor(private val dir : CPointer <DIR >) : AutoCloseable {
33
- actual fun readdir (): String? {
34
- val entry = readdir(dir) ? : return null
35
- return entry[0 ].d_name.toKString()
36
- }
37
-
38
- override fun close () {
39
- closedir(dir)
40
- }
41
- }
42
-
43
- @OptIn(ExperimentalForeignApi ::class )
44
- internal actual fun opendir (path : String ): OpaqueDirEntry {
45
- val dirent = platform.posix.opendir(path)
46
- if (dirent != null ) return OpaqueDirEntry (dirent)
47
- throw IOException (" Can't open directory $path : ${strerror(errno)?.toKString() ? : " reason unknown" } " )
48
- }
Original file line number Diff line number Diff line change @@ -60,23 +60,3 @@ internal actual fun realpathImpl(path: String): String {
60
60
return buffer.toKString()
61
61
}
62
62
}
63
-
64
-
65
- @OptIn(ExperimentalForeignApi ::class , ExperimentalStdlibApi ::class )
66
- internal actual class OpaqueDirEntry constructor(private val dir : CPointer <DIR >) : AutoCloseable {
67
- actual fun readdir (): String? {
68
- val entry = readdir(dir) ? : return null
69
- return entry[0 ].d_name.toKString()
70
- }
71
-
72
- override fun close () {
73
- closedir(dir)
74
- }
75
- }
76
-
77
- @OptIn(ExperimentalForeignApi ::class )
78
- internal actual fun opendir (path : String ): OpaqueDirEntry {
79
- val dirent = platform.posix.opendir(path)
80
- if (dirent != null ) return OpaqueDirEntry (dirent)
81
- throw IOException (" Can't open directory $path : ${strerror(errno)?.toKString() ? : " reason unknown" } " )
82
- }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
3
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
4
+ */
5
+
6
+ package kotlinx.io.files
7
+
8
+ import kotlinx.cinterop.CPointer
9
+ import kotlinx.cinterop.ExperimentalForeignApi
10
+ import kotlinx.cinterop.get
11
+ import kotlinx.cinterop.toKString
12
+ import kotlinx.io.IOException
13
+ import platform.posix.DIR
14
+ import platform.posix.closedir
15
+ import platform.posix.errno
16
+ import platform.posix.strerror
17
+
18
+ @OptIn(ExperimentalForeignApi ::class , ExperimentalStdlibApi ::class )
19
+ internal actual class OpaqueDirEntry constructor(private val dir : CPointer <DIR >) : AutoCloseable {
20
+ actual fun readdir (): String? {
21
+ val entry = platform.posix.readdir(dir) ? : return null
22
+ return entry[0 ].d_name.toKString()
23
+ }
24
+
25
+ override fun close () {
26
+ closedir(dir)
27
+ }
28
+ }
29
+
30
+ @OptIn(ExperimentalForeignApi ::class )
31
+ internal actual fun opendir (path : String ): OpaqueDirEntry {
32
+ val dirent = platform.posix.opendir(path)
33
+ if (dirent != null ) return OpaqueDirEntry (dirent)
34
+ throw IOException (" Can't open directory $path : ${strerror(errno)?.toKString() ? : " reason unknown" } " )
35
+ }
You can’t perform that action at this time.
0 commit comments