From 538a907f4857be9d7ce52ebdc1ac2dd49e39ed35 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 26 May 2024 20:06:00 +0800 Subject: [PATCH] Fix bug on windows --- lib/platform/image_cache_io.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/platform/image_cache_io.dart b/lib/platform/image_cache_io.dart index 6189c7a..95c299c 100644 --- a/lib/platform/image_cache_io.dart +++ b/lib/platform/image_cache_io.dart @@ -138,6 +138,14 @@ class ImageCaches { String p = path.join(dir.path, u.host.isEmpty ? "nohost" : u.host, u.path.substring(1) + (u.hasQuery ? "?${u.query}" : "")); final d = _fs.directory(path.dirname(p)); + if (isWindows) { + if (path.isAbsolute(p)) { + p = p.substring(0, 2) + + p.substring(2).replaceAll(RegExp("[:\\*\\?\"\\<\\>\\|]"), '_'); + } else { + p = p.replaceAll(RegExp("[:\\*\\?\"\\<\\>\\|]"), '_'); + } + } if (!(await d.exists())) { await d.create(recursive: true); }