From e0dbda7026c4cf3a81b82aa37c085991bee35758 Mon Sep 17 00:00:00 2001 From: OSrcD Date: Mon, 12 Jan 2026 03:16:02 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9E=20=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=89=AB=E6=8F=8FAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/codeocean/cheese/backend/impl/FilesImpl.kt | 4 ++++ .../java/net/codeocean/cheese/core/api/Files.kt | 1 + .../net/codeocean/cheese/core/utils/FilesUtils.kt | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/core/src/main/java/net/codeocean/cheese/backend/impl/FilesImpl.kt b/core/src/main/java/net/codeocean/cheese/backend/impl/FilesImpl.kt index 2374f31..e13d778 100644 --- a/core/src/main/java/net/codeocean/cheese/backend/impl/FilesImpl.kt +++ b/core/src/main/java/net/codeocean/cheese/backend/impl/FilesImpl.kt @@ -51,4 +51,8 @@ object FilesImpl : Files { override fun save(obj: Any, filePath: String): Boolean { return FilesUtils.save(obj, filePath) } + + override fun scanFile(path: String) { + return FilesUtils.scanFile(path) + } } \ No newline at end of file diff --git a/core/src/main/java/net/codeocean/cheese/core/api/Files.kt b/core/src/main/java/net/codeocean/cheese/core/api/Files.kt index d844998..933a81a 100644 --- a/core/src/main/java/net/codeocean/cheese/core/api/Files.kt +++ b/core/src/main/java/net/codeocean/cheese/core/api/Files.kt @@ -11,4 +11,5 @@ interface Files { fun append(filePath: String, content: String): Boolean fun write(filePath: String, content: String): Boolean fun save(obj: Any, filePath: String): Boolean + fun scanFile(path: String) } \ No newline at end of file diff --git a/core/src/main/java/net/codeocean/cheese/core/utils/FilesUtils.kt b/core/src/main/java/net/codeocean/cheese/core/utils/FilesUtils.kt index 6044181..54935f3 100644 --- a/core/src/main/java/net/codeocean/cheese/core/utils/FilesUtils.kt +++ b/core/src/main/java/net/codeocean/cheese/core/utils/FilesUtils.kt @@ -14,6 +14,8 @@ import java.io.FileWriter import java.io.IOException import java.io.InputStream import java.io.OutputStream +import android.media.MediaScannerConnection +import net.codeocean.cheese.core.CoreEnv object FilesUtils { @@ -389,4 +391,15 @@ object FilesUtils { return result } + fun scanFile(path: String) { + synchronized(this) { + MediaScannerConnection.scanFile( + CoreEnv.envContext.context, + arrayOf(path), + null, + null + ) + } + } + } \ No newline at end of file