Changed: optimise find next file
This commit is contained in:
parent
fbb25bad30
commit
c551b04e9e
@ -214,16 +214,31 @@ namespace RyzStudio.IO
|
||||
string filename = Path.GetFileName(filepath);
|
||||
if (string.IsNullOrWhiteSpace(filename)) return null;
|
||||
|
||||
List<string> 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)
|
||||
|
@ -11,7 +11,7 @@
|
||||
<Copyright>Ray Lam</Copyright>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
<NoWin32Manifest>true</NoWin32Manifest>
|
||||
<Version>0.1.1.008</Version>
|
||||
<Version>0.1.1.022</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
Loading…
Reference in New Issue
Block a user