Drop deprecations: io and threading functions.

This commit is contained in:
Ilya Gorbunov
2016-01-19 20:25:01 +03:00
parent 25c4453dc5
commit b39b29dfea
8 changed files with 43 additions and 166 deletions
@@ -41,12 +41,7 @@ public fun thread(start: Boolean = true, isDaemon: Boolean = false, contextClass
return thread
}
@Deprecated("Use thread function with the 'isDaemon' parameter")
public fun thread(start: Boolean = true, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, daemon: Boolean, block: () -> Unit): Thread =
thread(start = start, isDaemon = daemon, contextClassLoader = contextClassLoader, name = name, priority = priority, block = block)
/**
/**
* Gets the value in the current thread's copy of this
* thread-local variable or replaces the value with the result of calling
* [default] function in case if that value was `null`.
+3 -5
View File
@@ -8,16 +8,14 @@ package kotlin.io
*/
public val DEFAULT_BUFFER_SIZE: Int = 64 * 1024
@Deprecated("Use DEFAULT_BUFFER_SIZE constant instead.", ReplaceWith("kotlin.io.DEFAULT_BUFFER_SIZE"))
@Deprecated("Use DEFAULT_BUFFER_SIZE constant instead.", ReplaceWith("kotlin.io.DEFAULT_BUFFER_SIZE"), level = DeprecationLevel.ERROR)
public val defaultBufferSize: Int = DEFAULT_BUFFER_SIZE
/**
* Returns the default block size for forEachBlock().
*/
@Deprecated("This constant will become private soon, use its value instead.", ReplaceWith("4096"))
public val defaultBlockSize: Int = 4096
internal val defaultBlockSize: Int = 4096
/**
* Returns the minimum block size for forEachBlock().
*/
@Deprecated("This constant will become private soon, use its value instead.", ReplaceWith("512"))
public val minimumBlockSize: Int = 512
internal val minimumBlockSize: Int = 512
@@ -6,9 +6,6 @@ import java.io.*
import java.nio.charset.Charset
import java.util.NoSuchElementException
@Deprecated("It's not recommended to iterate through input stream of bytes unless it's buffered. Use buffered() extension on stream to make it buffered.", ReplaceWith("this.buffered().iterator()"))
public operator fun InputStream.iterator(): ByteIterator = buffered().iterator()
/** Returns an [Iterator] of bytes read from this input stream. */
public operator fun BufferedInputStream.iterator(): ByteIterator =
object : ByteIterator() {
+5 -99
View File
@@ -45,68 +45,12 @@ public fun createTempFile(prefix: String = "tmp", suffix: String? = null, direct
return File.createTempFile(prefix, suffix, directory)
}
/**
* Returns this if this file is a directory, or the parent if it is a file inside a directory.
*/
@Deprecated("This property has unclear semantics and will be removed soon.")
public val File.directory: File
get() = if (isDirectory) this else parentFile!!
/**
* Returns parent of this abstract path name, or `null` if it has no parent.
*/
@Deprecated("Use 'parentFile' property instead.", ReplaceWith("parentFile"), DeprecationLevel.ERROR)
public val File.parent: File?
get() = parentFile
/**
* Returns the extension of this file (not including the dot), or an empty string if it doesn't have one.
*/
public val File.extension: String
get() = name.substringAfterLast('.', "")
/**
* Replaces all separators in the string used to separate directories with system ones and returns the resulting string.
*
* @return the pathname with system separators.
*/
@Deprecated("Use File.path instead", ReplaceWith("File(this).path", "java.io.File"))
public fun String.separatorsToSystem(): String {
val otherSep = if (File.separator == "/") "\\" else "/"
return replace(otherSep, File.separator)
}
/**
* Replaces all path separators in the string with system ones and returns the resulting string.
*
* @return the pathname with system separators.
*/
@Deprecated("This function is deprecated")
public fun String.pathSeparatorsToSystem(): String {
val otherSep = if (File.pathSeparator == ":") ";" else ":"
return replace(otherSep, File.pathSeparator)
}
/**
* Replaces path and directories separators with corresponding system ones and returns the resulting string.
*
* @return the pathname with system separators.
*/
@Deprecated("This function is deprecated")
public fun String.allSeparatorsToSystem(): String {
return separatorsToSystem().pathSeparatorsToSystem()
}
/**
* Returns a pathname of this file with all path separators replaced with File.pathSeparator.
*
* @return the pathname with system separators.
*/
@Deprecated("File has already system separators.")
public fun File.separatorsToSystem(): String {
return toString().separatorsToSystem()
}
/**
* Returns [path] of this File using the invariant separator '/' to
* separate the names in the name sequence.
@@ -120,20 +64,6 @@ public val File.invariantSeparatorsPath: String
public val File.nameWithoutExtension: String
get() = name.substringBeforeLast(".")
/**
* Calculates the relative path for this file from [base] file.
* Note that the [base] file is treated as a directory.
* If this file matches the [base] file, then an empty string will be returned.
*
* @return relative path from [base] to this.
*
* @throws IllegalArgumentException if this and base paths have different roots.
*/
@Deprecated("This function will change return type to File soon. Use toRelativeString instead.", ReplaceWith("toRelativeString(base)"))
public fun File.relativeTo(base: File): String
= toRelativeString(base)
/**
* Calculates the relative path for this file from [base] file.
* Note that the [base] file is treated as a directory.
@@ -155,8 +85,10 @@ public fun File.toRelativeString(base: File): String
*
* @throws IllegalArgumentException if this and base paths have different roots.
*/
@Deprecated("This function will be renamed to relativeTo soon.")
public fun File.relativeToFile(base: File): File = File(this.relativeTo(base))
public fun File.relativeTo(base: File): File = File(this.toRelativeString(base))
@Deprecated("Use relativeTo instead.", ReplaceWith("this.relativeTo(base)"), level = DeprecationLevel.WARNING)
public fun File.relativeToFile(base: File): File = File(this.toRelativeString(base))
/**
@@ -225,25 +157,6 @@ private fun File.toRelativeStringOrNull(base: File): String? {
return res.toString()
}
/**
* Calculates the relative path for this file from [descendant] file.
* Note that the [descendant] file is treated as a directory.
* If this file matches the [descendant] directory or does not belong to it,
* then an empty string will be returned.
*/
@Deprecated("Use relativeTo() function instead")
public fun File.relativePath(descendant: File): String {
val prefix = directory.canonicalPath
val answer = descendant.canonicalPath
return if (answer.startsWith(prefix)) {
val prefixSize = prefix.length
if (answer.length > prefixSize) {
answer.substring(prefixSize + 1)
} else ""
} else {
answer
}
}
/**
* Copies this file to the given output [dst], returning the number of bytes copied.
@@ -338,7 +251,7 @@ public fun File.copyRecursively(dst: File,
OnErrorAction.TERMINATE)
return false
} else {
val relPath = src.relativeTo(this)
val relPath = src.toRelativeString(this)
val dstFile = File(dst, relPath)
if (dstFile.exists() && !(src.isDirectory && dstFile.isDirectory)) {
if (onError(dstFile, FileAlreadyExistsException(file = src,
@@ -369,13 +282,6 @@ public fun File.copyRecursively(dst: File,
*/
public fun File.deleteRecursively(): Boolean = walkBottomUp().fold(true, { res, it -> (it.delete() || !it.exists()) && res })
/**
* Returns an array of files and directories in the directory that match the specified [filter]
* or `null` if this file does not denote a directory.
*/
@Deprecated("Provided for binary compatiblity", level = DeprecationLevel.HIDDEN)
public fun File.listFiles(filter: (file: File) -> Boolean): Array<File>? = listFiles(FileFilter(filter))
/**
* Determines whether this file belongs to the same root as [other]
* and starts with all components of [other] in the same order.