Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 750ac361 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Remove unused moveRecursive()

parent a11fd554
Loading
Loading
Loading
Loading
+0 −50
Original line number Diff line number Diff line
@@ -70,54 +70,4 @@ object FileHelper {
            false
        }
    }

    @JvmStatic
    fun moveRecursive(fromDir: File, toDir: File) {
        if (!fromDir.exists()) {
            return
        }
        if (!fromDir.isDirectory()) {
            if (toDir.exists()) {
                if (!toDir.delete()) {
                    Timber.w("cannot delete already existing file/directory %s", toDir.absolutePath)
                }
            }
            if (!fromDir.renameTo(toDir)) {
                Timber.w("cannot rename %s to %s - moving instead", fromDir.absolutePath, toDir.absolutePath)
                move(fromDir, toDir)
            }
            return
        }
        if (!toDir.exists() || !toDir.isDirectory()) {
            if (toDir.exists()) {
                if (!toDir.delete()) {
                    Timber.d("Unable to delete file: %s", toDir.absolutePath)
                }
            }
            if (!toDir.mkdirs()) {
                Timber.w("cannot create directory %s", toDir.absolutePath)
            }
        }
        val files = fromDir.listFiles().orEmpty()
        for (file in files) {
            if (file.isDirectory()) {
                moveRecursive(file, File(toDir, file.getName()))
                if (!file.delete()) {
                    Timber.d("Unable to delete file: %s", toDir.absolutePath)
                }
            } else {
                val target = File(toDir, file.getName())
                if (!file.renameTo(target)) {
                    Timber.w(
                        "cannot rename %s to %s - moving instead",
                        file.absolutePath, target.absolutePath,
                    )
                    move(file, target)
                }
            }
        }
        if (!fromDir.delete()) {
            Timber.w("cannot delete %s", fromDir.absolutePath)
        }
    }
}