From f26d5057a03c40dd43fae5e6651c7bb2291021d4 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 03:03:58 +0000 Subject: [PATCH] Modernize and secure temp file creation --- .../kunfei/bookshelf/widget/filepicker/util/StorageUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/kunfei/bookshelf/widget/filepicker/util/StorageUtils.java b/app/src/main/java/com/kunfei/bookshelf/widget/filepicker/util/StorageUtils.java index b0100d8625..2fbea1e21a 100644 --- a/app/src/main/java/com/kunfei/bookshelf/widget/filepicker/util/StorageUtils.java +++ b/app/src/main/java/com/kunfei/bookshelf/widget/filepicker/util/StorageUtils.java @@ -6,6 +6,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; /** * 存储设备工具类 @@ -152,7 +153,7 @@ public static String getTempDirPath(Context context) { */ public static String getTempFilePath(Context context) { try { - return File.createTempFile("lyj_", ".tmp", context.getCacheDir()).getAbsolutePath(); + return Files.createTempFile(context.getCacheDir().toPath(), "lyj_", ".tmp").toFile().getAbsolutePath(); } catch (IOException e) { return getTempDirPath(context) + "lyj.tmp"; }