Skip to content

Commit

Permalink
v2.4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Sep 6, 2021
1 parent a77aa69 commit 8046ee7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Common.CoreLib/IOPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ public static string GetFileResourcePath(byte[] resData, string resName, int res
public static bool? IsDirectory(string path, [NotNullWhen(false)] out FileInfo? fileInfo, [NotNullWhen(true)] out DirectoryInfo? directoryInfo)
{
fileInfo = new(path);
if (fileInfo.Exists)
if (fileInfo.Exists) // 路径为文件
{
directoryInfo = null;
return false;
}
fileInfo = null;
directoryInfo = new(path);
if (directoryInfo.Exists)
if (directoryInfo.Exists) // 路径为文件夹
{
return true;
}
Expand Down
36 changes: 31 additions & 5 deletions src/ST.Client.Desktop/Services/IDesktopPlatformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,41 @@ void IPlatformService.OpenFileByTextReader(string filePath)
/// <param name="path"></param>
void OpenFolder(string path)
{
var isDirectory = IOPath.IsDirectory(path, out var fileInfo, out var directoryInfo);
if (!isDirectory.HasValue) return;
if (isDirectory.Value)
sbyte isDirectory = -1;
FileInfo? fileInfo;
DirectoryInfo directoryInfo = new(path);
if (directoryInfo.Exists) // 路径为文件夹,则打开文件夹
{
OpenFolderByDirectoryPath(directoryInfo!);
fileInfo = null;
isDirectory = 1;
}
else
{
OpenFolderSelectFilePath(fileInfo!);
fileInfo = new(path);
if (fileInfo.Exists) // 路径为文件,则打开文件
{
isDirectory = 0;
}
else if (fileInfo.DirectoryName != null)
{
directoryInfo = new(fileInfo.DirectoryName);
fileInfo = null;
if (directoryInfo.Exists) // 路径为文件但文件不存在,文件夹存在,则打开文件夹
{
fileInfo = null;
isDirectory = 1;
}
}
}

switch (isDirectory)
{
case 1:
if (directoryInfo != null) OpenFolderByDirectoryPath(directoryInfo);
break;
case 0:
if (fileInfo != null) OpenFolderSelectFilePath(fileInfo);
break;
}
}

Expand Down

0 comments on commit 8046ee7

Please sign in to comment.