Initial work
diff --git a/libraries/stdlib/jvm/src/kotlin/io/Exceptions.kt b/libraries/stdlib/jvm/src/kotlin/io/Exceptions.kt index a83fc4b..70456ac 100644 --- a/libraries/stdlib/jvm/src/kotlin/io/Exceptions.kt +++ b/libraries/stdlib/jvm/src/kotlin/io/Exceptions.kt
@@ -25,6 +25,7 @@ * @property other the second file involved in the operation, if any (for example, the target of a copy or move) * @property reason the description of the error */ +@Deprecated("", level = DeprecationLevel.ERROR) open public class FileSystemException( public val file: File, public val other: File? = null, @@ -34,27 +35,30 @@ /** * An exception class which is used when some file to create or copy to already exists. */ -public class FileAlreadyExistsException( +@Deprecated("", level = DeprecationLevel.ERROR) +public open class FileAlreadyExistsException( file: File, other: File? = null, reason: String? = null -) : FileSystemException(file, other, reason) +) : kotlin.io.exceptions.FileSystemException(file, other, reason) /** * An exception class which is used when we have not enough access for some operation. */ -public class AccessDeniedException( +@Deprecated("", level = DeprecationLevel.ERROR) +public open class AccessDeniedException( file: File, other: File? = null, reason: String? = null -) : FileSystemException(file, other, reason) +) : kotlin.io.exceptions.FileSystemException(file, other, reason) /** * An exception class which is used when file to copy does not exist. */ -public class NoSuchFileException( +@Deprecated("", level = DeprecationLevel.ERROR) +public open class NoSuchFileException( file: File, other: File? = null, reason: String? = null -) : FileSystemException(file, other, reason) +) : kotlin.io.exceptions.FileSystemException(file, other, reason)
diff --git a/libraries/stdlib/jvm/src/kotlin/io/files/Exceptions.kt b/libraries/stdlib/jvm/src/kotlin/io/files/Exceptions.kt new file mode 100644 index 0000000..7800635 --- /dev/null +++ b/libraries/stdlib/jvm/src/kotlin/io/files/Exceptions.kt
@@ -0,0 +1,52 @@ +/* + * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.io.exceptions + +import java.io.File + +/** + * A base exception class for file system exceptions. + * @property file the file on which the failed operation was performed. + * @property other the second file involved in the operation, if any (for example, the target of a copy or move) + * @property reason the description of the error + */ +@Suppress("DEPRECATION_ERROR") +open public class FileSystemException( + file: File, + other: File? = null, + reason: String? = null +) : kotlin.io.FileSystemException(file, other, reason) + +/** + * An exception class which is used when some file to create or copy to already exists. + */ +@Suppress("DEPRECATION_ERROR") +public class FileAlreadyExistsException( + file: File, + other: File? = null, + reason: String? = null +) : kotlin.io.FileAlreadyExistsException(file, other, reason) + +/** + * An exception class which is used when we have not enough access for some operation. + */ +@Suppress("DEPRECATION_ERROR") +public class AccessDeniedException( + file: File, + other: File? = null, + reason: String? = null +) : kotlin.io.AccessDeniedException(file, other, reason) + +/** + * An exception class which is used when file to copy does not exist. + */ +@Suppress("DEPRECATION_ERROR") +public class NoSuchFileException( + file: File, + other: File? = null, + reason: String? = null +) : kotlin.io.NoSuchFileException(file, other, reason) +
diff --git a/libraries/stdlib/jvm/src/kotlin/io/files/FileTreeWalk.kt b/libraries/stdlib/jvm/src/kotlin/io/files/FileTreeWalk.kt index 58bb360..bfeeb93 100644 --- a/libraries/stdlib/jvm/src/kotlin/io/files/FileTreeWalk.kt +++ b/libraries/stdlib/jvm/src/kotlin/io/files/FileTreeWalk.kt
@@ -11,6 +11,7 @@ import java.io.File import java.io.IOException import java.util.ArrayDeque +import kotlin.io.exceptions.AccessDeniedException /** * An enumeration to describe possible walk directions.
diff --git a/libraries/stdlib/jvm/src/kotlin/io/files/Utils.kt b/libraries/stdlib/jvm/src/kotlin/io/files/Utils.kt index c376916..19e7484 100644 --- a/libraries/stdlib/jvm/src/kotlin/io/files/Utils.kt +++ b/libraries/stdlib/jvm/src/kotlin/io/files/Utils.kt
@@ -10,6 +10,9 @@ import java.io.File import java.io.IOException +import kotlin.io.exceptions.FileSystemException +import kotlin.io.exceptions.NoSuchFileException +import kotlin.io.exceptions.FileAlreadyExistsException /** * Creates an empty directory in the specified [directory], using the given [prefix] and [suffix] to generate its name.
diff --git a/libraries/stdlib/jvm/test/io/Files.kt b/libraries/stdlib/jvm/test/io/Files.kt index a5db296..c8ce290 100644 --- a/libraries/stdlib/jvm/test/io/Files.kt +++ b/libraries/stdlib/jvm/test/io/Files.kt
@@ -430,6 +430,7 @@ } } + @Suppress("DEPRECATION_ERROR") @Test fun testCopyTo() { val srcFile = @Suppress("DEPRECATION") createTempFile() val dstFile = @Suppress("DEPRECATION") createTempFile() @@ -567,7 +568,7 @@ } } - @Suppress("DEPRECATION") + @Suppress("DEPRECATION", "DEPRECATION_ERROR") @Test fun copyRecursively() { val src = createTempDir() val dst = createTempDir()