File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
app/src/main/kotlin/org/fossify/filemanager/activities Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -154,21 +154,19 @@ class SaveAsActivity : SimpleActivity() {
154154 return try {
155155 val originalFilename = getFilenameFromContentUri(source)
156156 ? : source.toString().getFilenameFromPath()
157- ? : " file_$index "
158- val filename = originalFilename.replace(" [/\\\\ <>:\" |?*\u0000 -\u001F ]" .toRegex(), " _" )
159- .takeIf { it.isNotBlank() } ? : " unnamed_file"
157+ val filename = sanitizeFilename(originalFilename)
160158
161159 val mimeType = contentResolver.getType(source)
162160 ? : mimeTypes?.getOrNull(index)?.takeIf { it != " */*" }
163161 ? : intent.type?.takeIf { it != " */*" }
164162 ? : filename.getMimeType()
165163
166164 val inputStream = contentResolver.openInputStream(source)
167- ? : throw IOException (" Cannot open input stream " )
165+ ? : throw IOException (getString( R .string.error, source) )
168166
169167 val destinationPath = getAvailablePath(" $destination /$filename " )
170168 val outputStream = getFileOutputStreamSync(destinationPath, mimeType, null )
171- ? : throw IOException (" Cannot create output stream " )
169+ ? : throw IOException (getString( R .string.error, source) )
172170
173171 inputStream.use { input ->
174172 outputStream.use { output ->
You can’t perform that action at this time.
0 commit comments