File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
app/src/main/kotlin/org/fossify/filemanager/activities Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ class SaveAsActivity : SimpleActivity() {
5858 ? : filename.getMimeType()
5959 val inputStream = contentResolver.openInputStream(source)
6060
61- val destinationPath = setAvailablePath (" $destination /$filename " )
61+ val destinationPath = getAvailablePath (" $destination /$filename " )
6262 val outputStream = getFileOutputStreamSync(destinationPath, mimeType, null )!!
6363 inputStream!! .copyTo(outputStream)
6464 rescanPaths(arrayListOf (destinationPath))
@@ -87,17 +87,16 @@ class SaveAsActivity : SimpleActivity() {
8787 .takeIf { it.isNotBlank() } ? : " unnamed_file"
8888 }
8989
90- private fun setAvailablePath (path : String ): String {
91- val file = File (path)
92-
93- return if (! file.exists()) {
94- path
95- } else {
96- findAvailableNameForExistingFile(file)
90+ private fun getAvailablePath (destinationPath : String ): String {
91+ if (! getDoesFilePathExist(destinationPath)) {
92+ return destinationPath
9793 }
94+
95+ val file = File (destinationPath)
96+ return findAvailableName(file)
9897 }
9998
100- private fun findAvailableNameForExistingFile (file : File ): String {
99+ private fun findAvailableName (file : File ): String {
101100 val parent = file.parent ? : return file.absolutePath
102101 val name = file.nameWithoutExtension
103102 val ext = if (file.extension.isNotEmpty()) " .${file.extension} " else " "
You can’t perform that action at this time.
0 commit comments