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);
|
string filename = Path.GetFileName(filepath);
|
||||||
if (string.IsNullOrWhiteSpace(filename)) return null;
|
if (string.IsNullOrWhiteSpace(filename)) return null;
|
||||||
|
|
||||||
List<string> fileList = AccessibleDirectory.GetFiles(path, pattern, true);
|
bool returnNext = false;
|
||||||
if (fileList == null) return null;
|
foreach (string item in Directory.EnumerateFiles(path, "*", SearchOption.TopDirectoryOnly))
|
||||||
if (fileList.Count <= 0) return null;
|
{
|
||||||
if (fileList.Count(x => (Path.GetFileName(x).Equals(filename))) < 0) return null;
|
if (!MatchFileSearchPattern(pattern, Path.GetFileName(item)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int pos = fileList.FindIndex(x => Path.GetFileName(x).Equals(filename));
|
if (!IsFileAccessible(item))
|
||||||
if (pos < 0) return null;
|
{
|
||||||
if (pos >= (fileList.Count - 1)) return null;
|
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)
|
public static bool IsAccessible(string path)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<Copyright>Ray Lam</Copyright>
|
<Copyright>Ray Lam</Copyright>
|
||||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||||
<NoWin32Manifest>true</NoWin32Manifest>
|
<NoWin32Manifest>true</NoWin32Manifest>
|
||||||
<Version>0.1.1.008</Version>
|
<Version>0.1.1.022</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
Loading…
Reference in New Issue
Block a user