File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
commons/src/main/kotlin/org/fossify/commons/extensions Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1274,13 +1274,19 @@ private fun BaseSimpleActivity.renameCasually(
12741274
12751275fun Activity.createTempFile (file : File ): File ? {
12761276 return if (file.isDirectory) {
1277- createTempDir(" temp" , " ${System .currentTimeMillis()} " , file.parentFile)
1277+ val dir = File .createTempFile(" temp" , " ${System .currentTimeMillis()} " , file.parentFile)
1278+ dir.delete()
1279+ if (dir.mkdir()) {
1280+ return dir
1281+ } else {
1282+ throw IOException (" Unable to create temporary directory $dir ." )
1283+ }
12781284 } else {
12791285 if (isRPlus()) {
12801286 // this can throw FileSystemException, lets catch and handle it at the place calling this function
12811287 kotlin.io.path.createTempFile(file.parentFile.toPath(), " temp" , " ${System .currentTimeMillis()} " ).toFile()
12821288 } else {
1283- createTempFile(" temp" , " ${System .currentTimeMillis()} " , file.parentFile)
1289+ File . createTempFile(" temp" , " ${System .currentTimeMillis()} " , file.parentFile)
12841290 }
12851291 }
12861292}
You can’t perform that action at this time.
0 commit comments