From c551b04e9e03eed481fd33cbce5b853da0892b11 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 7 Nov 2021 13:30:05 +0000 Subject: [PATCH] Changed: optimise find next file --- RyzStudio/IO/AccessibleDirectory.cs | 31 +++++++++++++++++++++-------- VideoPreview.csproj | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/RyzStudio/IO/AccessibleDirectory.cs b/RyzStudio/IO/AccessibleDirectory.cs index a4af53d..7881a2c 100644 --- a/RyzStudio/IO/AccessibleDirectory.cs +++ b/RyzStudio/IO/AccessibleDirectory.cs @@ -214,16 +214,31 @@ namespace RyzStudio.IO string filename = Path.GetFileName(filepath); if (string.IsNullOrWhiteSpace(filename)) return null; - List fileList = AccessibleDirectory.GetFiles(path, pattern, true); - if (fileList == null) return null; - if (fileList.Count <= 0) return null; - if (fileList.Count(x => (Path.GetFileName(x).Equals(filename))) < 0) return null; + bool returnNext = false; + foreach (string item in Directory.EnumerateFiles(path, "*", SearchOption.TopDirectoryOnly)) + { + if (!MatchFileSearchPattern(pattern, Path.GetFileName(item))) + { + continue; + } - int pos = fileList.FindIndex(x => Path.GetFileName(x).Equals(filename)); - if (pos < 0) return null; - if (pos >= (fileList.Count - 1)) return null; + if (!IsFileAccessible(item)) + { + continue; + } - return fileList[(pos + 1)]; + if (returnNext) + { + return item; + } + + if (Path.GetFileName(item).Equals(filename)) + { + returnNext = true; + } + } + + return null; } public static bool IsAccessible(string path) diff --git a/VideoPreview.csproj b/VideoPreview.csproj index 1859923..a12acfc 100644 --- a/VideoPreview.csproj +++ b/VideoPreview.csproj @@ -11,7 +11,7 @@ Ray Lam favicon.ico true - 0.1.1.008 + 0.1.1.022