Skip to content

Commit

Permalink
Clarify copyRecursively behavior in case of a single file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-g committed Apr 18, 2017
1 parent 7ebd867 commit 59dc0f5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions libraries/stdlib/src/kotlin/io/files/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ private fun File.toRelativeStringOrNull(base: File): String? {
* If this file is a directory, it is copied without its content, i.e. an empty [target] directory is created.
* If you want to copy directory including its contents, use [copyRecursively].
*
* The operation doesn't preserve copied file attributes such as creation/modification date, permissions, etc.
*
* @param overwrite `true` if destination overwrite is allowed.
* @param bufferSize the buffer size to use when copying.
* @return the [target] file.
Expand Down Expand Up @@ -222,20 +224,29 @@ private class TerminateException(file: File) : FileSystemException(file) {}
* Copies this file with all its children to the specified destination [target] path.
* If some directories on the way to the destination are missing, then they will be created.
*
* If this file path points to a single file, then it will be copied to a file with the path [target].
* If this file path points to a directory, then its children will be copied to a directory with the path [target].
*
* If the [target] already exists, it will be deleted before copying when the [overwrite] parameter permits so.
*
* The operation doesn't preserve copied file attributes such as creation/modification date, permissions, etc.
*
* If any errors occur during the copying, then further actions will depend on the result of the call
* to `onError(File, IOException)` function, that will be called with arguments,
* specifying the file that caused the error and the exception itself.
* By default this function rethrows exceptions.
*
* Exceptions that can be passed to the `onError` function:
* NoSuchFileException - if there was an attempt to copy a non-existent file
* FileAlreadyExistsException - if there is a conflict
* AccessDeniedException - if there was an attempt to open a directory that didn't succeed.
* IOException - if some problems occur when copying.
*
* - [NoSuchFileException] - if there was an attempt to copy a non-existent file
* - [FileAlreadyExistsException] - if there is a conflict
* - [AccessDeniedException] - if there was an attempt to open a directory that didn't succeed.
* - [IOException] - if some problems occur when copying.
*
* Note that if this function fails, then partial copying may have taken place.
*
* @param overwrite `true` if it is allowed to overwrite existing destination files and directories.
* @return `false` if the copying was terminated, `true` otherwise.
*
* Note that if this function fails, then partial copying may have taken place.
*/
public fun File.copyRecursively(target: File,
overwrite: Boolean = false,
Expand Down

0 comments on commit 59dc0f5

Please sign in to comment.