Skip to content

Commit 49552d0

Browse files
committed
Return a Collection instead of List
1 parent 16f761f commit 49552d0

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

core/api/kotlinx-io-core.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public abstract interface class kotlinx/io/files/FileSystem {
213213
public abstract fun delete (Lkotlinx/io/files/Path;Z)V
214214
public static synthetic fun delete$default (Lkotlinx/io/files/FileSystem;Lkotlinx/io/files/Path;ZILjava/lang/Object;)V
215215
public abstract fun exists (Lkotlinx/io/files/Path;)Z
216-
public abstract fun list (Lkotlinx/io/files/Path;)Ljava/util/List;
216+
public abstract fun list (Lkotlinx/io/files/Path;)Ljava/util/Collection;
217217
public abstract fun metadataOrNull (Lkotlinx/io/files/Path;)Lkotlinx/io/files/FileMetadata;
218218
public abstract fun resolve (Lkotlinx/io/files/Path;)Lkotlinx/io/files/Path;
219219
public abstract fun sink (Lkotlinx/io/files/Path;Z)Lkotlinx/io/RawSink;

core/api/kotlinx-io-core.klib.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ sealed interface kotlinx.io.files/FileSystem { // kotlinx.io.files/FileSystem|nu
162162
abstract fun createDirectories(kotlinx.io.files/Path, kotlin/Boolean =...) // kotlinx.io.files/FileSystem.createDirectories|createDirectories(kotlinx.io.files.Path;kotlin.Boolean){}[0]
163163
abstract fun delete(kotlinx.io.files/Path, kotlin/Boolean =...) // kotlinx.io.files/FileSystem.delete|delete(kotlinx.io.files.Path;kotlin.Boolean){}[0]
164164
abstract fun exists(kotlinx.io.files/Path): kotlin/Boolean // kotlinx.io.files/FileSystem.exists|exists(kotlinx.io.files.Path){}[0]
165-
abstract fun list(kotlinx.io.files/Path): kotlin.collections/List<kotlinx.io.files/Path> // kotlinx.io.files/FileSystem.list|list(kotlinx.io.files.Path){}[0]
165+
abstract fun list(kotlinx.io.files/Path): kotlin.collections/Collection<kotlinx.io.files/Path> // kotlinx.io.files/FileSystem.list|list(kotlinx.io.files.Path){}[0]
166166
abstract fun metadataOrNull(kotlinx.io.files/Path): kotlinx.io.files/FileMetadata? // kotlinx.io.files/FileSystem.metadataOrNull|metadataOrNull(kotlinx.io.files.Path){}[0]
167167
abstract fun resolve(kotlinx.io.files/Path): kotlinx.io.files/Path // kotlinx.io.files/FileSystem.resolve|resolve(kotlinx.io.files.Path){}[0]
168168
abstract fun sink(kotlinx.io.files/Path, kotlin/Boolean =...): kotlinx.io/RawSink // kotlinx.io.files/FileSystem.sink|sink(kotlinx.io.files.Path;kotlin.Boolean){}[0]

core/common/src/files/FileSystem.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,23 @@ public sealed interface FileSystem {
147147
public fun resolve(path: Path): Path
148148

149149
/**
150-
* Returns a list of paths corresponding to [directory]'s immediate children.
150+
* Returns paths corresponding to [directory]'s immediate children.
151151
*
152-
* If path [directory] was an absolute path, a returned list will also contain absolute paths.
153-
* If it was a relative path, a returned list will contain relative paths.
152+
* There are no guarantees on children paths order within a returned collection.
153+
*
154+
* If path [directory] was an absolute path, a returned collection will also contain absolute paths.
155+
* If it was a relative path, a returned collection will contain relative paths.
154156
*
155157
* *For `wasmWasi` target, function does not work with NodeJS runtime on Windows,
156158
* as `fd_readdir` function is [not implemented there](https://github.com/nodejs/node/blob/6f4d6011ea1b448cf21f5d363c44e4a4c56ca34c/deps/uvwasi/src/uvwasi.c#L19).*
157159
*
158-
*
159160
* @param directory a directory to list.
160-
* @return a list of [directory]'s immediate children.
161+
* @return a collection of [directory]'s immediate children.
161162
* @throws FileNotFoundException if [directory] does not exist.
162163
* @throws IOException if [directory] points to something other than directory.
163164
* @throws IOException if there was an underlying error preventing listing [directory] children.
164165
*/
165-
public fun list(directory: Path): List<Path>
166+
public fun list(directory: Path): Collection<Path>
166167
}
167168

168169
internal abstract class SystemFileSystemImpl : FileSystem

core/jvm/src/files/FileSystemJvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public actual val SystemFileSystem: FileSystem = object : SystemFileSystemImpl()
9797
return Path(path.file.canonicalFile)
9898
}
9999

100-
override fun list(directory: Path): List<Path> {
100+
override fun list(directory: Path): Collection<Path> {
101101
val file = directory.file
102102
if (!file.exists()) throw FileNotFoundException(file.absolutePath)
103103
if (!file.isDirectory) throw IOException("Not a directory: ${file.absolutePath}")

core/native/src/files/FileSystemNative.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public actual val SystemFileSystem: FileSystem = object : SystemFileSystemImpl()
8787
return FileSink(openFile)
8888
}
8989

90-
override fun list(directory: Path): List<Path> {
90+
override fun list(directory: Path): Collection<Path> {
9191
val metadata = metadataOrNull(directory) ?: throw FileNotFoundException(directory.path)
9292
if (!metadata.isDirectory) throw IOException("Not a directory: ${directory.path}")
9393
return buildList {

core/nodeFilesystemShared/src/files/FileSystemNodeJs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public actual val SystemFileSystem: FileSystem = object : SystemFileSystemImpl()
101101
return Path(fs.realpathSync.native(path.path))
102102
}
103103

104-
override fun list(directory: Path): List<Path> {
104+
override fun list(directory: Path): Collection<Path> {
105105
val metadata = metadataOrNull(directory) ?: throw FileNotFoundException(directory.path)
106106
if (!metadata.isDirectory) throw IOException("Not a directory: ${directory.path}")
107107
val dir = fs.opendirSync(directory.path) ?: throw IOException("Unable to read directory: ${directory.path}")

core/wasmWasi/src/files/FileSystemWasm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ internal object WasiFileSystem : SystemFileSystemImpl() {
277277
}
278278
}
279279

280-
override fun list(directory: Path): List<Path> {
280+
override fun list(directory: Path): Collection<Path> {
281281
val preOpen = PreOpens.findPreopen(directory)
282282

283283
val metadata = metadataOrNullInternal(preOpen.fd, directory, true)

0 commit comments

Comments
 (0)