2.14.0.0
This commit is contained in:
@@ -6,12 +6,12 @@ Public Module ModBase
|
||||
#Region "声明"
|
||||
|
||||
'下列版本信息由更新器自动修改
|
||||
Public Const VersionBaseName As String = "2.13.1.1" '显示用版本名
|
||||
Public Const VersionBaseName As String = "2.14.0.0" '显示用版本名
|
||||
Public Const CommitHash As String = "" 'Commit Hash,由 GitHub Workflow 自动替换
|
||||
#If RELEASE Then
|
||||
Public Const VersionCode As Integer = 408 '正式版
|
||||
Public Const VersionCode As Integer = 411 '正式版
|
||||
#Else
|
||||
Public Const VersionCode As Integer = 410 '快照版
|
||||
Public Const VersionCode As Integer = 412 '快照版
|
||||
#End If
|
||||
|
||||
'版本信息
|
||||
@@ -47,7 +47,7 @@ Public Module ModBase
|
||||
''' <summary>
|
||||
''' 程序的缓存文件夹路径,以 \ 结尾。
|
||||
''' </summary>
|
||||
Public PathTemp As String = If(Settings.Get(Of String)("SystemSystemCache") = "", Path.GetTempPath() & "PCL\", Settings.Get(Of String)("SystemSystemCache")).ToString.Replace("/", "\").TrimEnd("\") & "\"
|
||||
Public PathTemp As String = PathUtils.AddSlashSuffix(If(Settings.Get(Of String)("SystemSystemCache") = "", Path.GetTempPath() & "PCL\", Settings.Get(Of String)("SystemSystemCache")).Replace("/", "\"))
|
||||
''' <summary>
|
||||
''' 当前程序的语言。
|
||||
''' </summary>
|
||||
@@ -75,7 +75,7 @@ Public Module ModBase
|
||||
''' <summary>
|
||||
''' 系统盘盘符,以 \ 结尾。例如 “C:\”。
|
||||
''' </summary>
|
||||
Public OsDrive As String = Environment.GetLogicalDrives().Where(Function(p) Directory.Exists(p)).First.Upper.First & ":\" '#3799
|
||||
Public OsDrive As String = Environment.GetLogicalDrives().First(Function(p) Directory.Exists(p)) '#3799
|
||||
|
||||
Public ReadOnly Property ModeDebug As Boolean
|
||||
Get
|
||||
@@ -576,7 +576,7 @@ Public Module ModBase
|
||||
Try
|
||||
If String.IsNullOrEmpty(Folder) Then Return False
|
||||
Folder = PathUtils.AddSlashSuffix(Folder)
|
||||
If Folder.EndsWithF(":\System Volume Information\") OrElse Folder.EndsWithF(":\$RECYCLE.BIN\") Then Return False
|
||||
If Folder.EndsWithF(":\System Volume Information\", True) OrElse Folder.EndsWithF(":\$RECYCLE.BIN\", True) Then Return False
|
||||
If Not DirectoryUtils.Exists(Folder) Then Return False
|
||||
Dim TestFilePath As String = $"{Folder}CheckPermission{GetUuid()}.txt"
|
||||
FileUtils.Write(TestFilePath, "临时文件,用于检测该文件夹的权限是否正常。")
|
||||
@@ -593,7 +593,7 @@ Public Module ModBase
|
||||
Public Sub CheckPermissionWithException(Folder As String)
|
||||
If String.IsNullOrWhiteSpace(Folder) Then Throw New ArgumentNullException("文件夹名不能为空!")
|
||||
Folder = PathUtils.AddSlashSuffix(Folder)
|
||||
If Folder.EndsWithF(":\System Volume Information\") OrElse Folder.EndsWithF(":\$RECYCLE.BIN\") Then Throw New UnauthorizedAccessException("没有对系统文件夹的权限!")
|
||||
If Folder.EndsWithF(":\System Volume Information\", True) OrElse Folder.EndsWithF(":\$RECYCLE.BIN\", True) Then Throw New UnauthorizedAccessException("没有对系统文件夹的权限!")
|
||||
If Not DirectoryUtils.Exists(Folder) Then Throw New DirectoryNotFoundException("文件夹不存在!")
|
||||
Dim TestFilePath As String = $"{Folder}CheckPermission{GetUuid()}.txt"
|
||||
FileUtils.Write(TestFilePath, "临时文件,用于检测该文件夹的权限是否正常。")
|
||||
@@ -788,7 +788,7 @@ Public Module ModBase
|
||||
''' <summary>
|
||||
''' 可用于临时存放文件的,不含任何特殊字符的文件夹路径,以“\”结尾。
|
||||
''' </summary>
|
||||
Public PathPure As Lazy(Of String) = New Lazy(Of String)(
|
||||
Public PathPure As New Lazy(Of String)(
|
||||
Function()
|
||||
If Paths.Base.IsAsciiOnly() Then
|
||||
Return Paths.Base & "PCL\"
|
||||
@@ -845,6 +845,12 @@ Public Module ModBase
|
||||
Return (Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000
|
||||
End Function
|
||||
''' <summary>
|
||||
''' 获取十进制 Unix 时间戳。
|
||||
''' </summary>
|
||||
Public Function ToUnixTimestampUtc(Time As Date) As Long
|
||||
Return (Time.ToUniversalTime().Ticks - 621355968000000000) / 10000000
|
||||
End Function
|
||||
''' <summary>
|
||||
''' 时间戳转化为日期。
|
||||
''' </summary>
|
||||
Public Function GetDate(timeStamp As Integer) As Date
|
||||
@@ -1021,20 +1027,22 @@ Public Module ModBase
|
||||
''' <summary>
|
||||
''' 设置剪贴板。将在另一线程运行,且不会抛出异常。
|
||||
''' </summary>
|
||||
Public Sub ClipboardSet(Text As String, Optional ShowSuccessHint As Boolean = True, Optional SuccessHint As String = "")
|
||||
Public Sub ClipboardSet(Text As String, Optional ShowSuccessHint As Boolean = True)
|
||||
RunInThread(
|
||||
Sub()
|
||||
RunInUi(
|
||||
Sub()
|
||||
Try
|
||||
My.Computer.Clipboard.Clear()
|
||||
If Not String.IsNullOrEmpty(Text) Then My.Computer.Clipboard.SetText(Text)
|
||||
If ShowSuccessHint Then Hint(If(String.IsNullOrEmpty(SuccessHint), "已成功复制!", SuccessHint), HintType.Green)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, behavior:=LogBehavior.None)
|
||||
Hint("复制失败,可能由于剪贴板被其他程序占用!", HintType.Red)
|
||||
End Try
|
||||
End Sub)
|
||||
Try
|
||||
Retrier.Attempt(delay:=Function(Attempt) TimeSpan.FromMilliseconds(200), maxAttempts:=4, isRetryAllowed:=Function(ex) True, action:=
|
||||
Sub()
|
||||
RunInUiWait(
|
||||
Sub()
|
||||
My.Computer.Clipboard.Clear()
|
||||
If Not String.IsNullOrEmpty(Text) Then My.Computer.Clipboard.SetText(Text)
|
||||
End Sub)
|
||||
End Sub)
|
||||
If ShowSuccessHint Then Hint("已成功复制!", HintType.Green)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "可能由于剪贴板被其他程序占用,文本复制失败", LogBehavior.Toast)
|
||||
End Try
|
||||
End Sub)
|
||||
End Sub
|
||||
''' <summary>
|
||||
|
||||
@@ -1396,7 +1396,7 @@ FinishExCatch:
|
||||
Public Overrides Sub Start(Optional Input As Object = Nothing, Optional IsForceRestart As Boolean = False)
|
||||
If Input IsNot Nothing Then Files = New ConcurrentQueue(Of NetFile)(CType(Input, IEnumerable(Of NetFile)))
|
||||
'去重
|
||||
Files = New ConcurrentQueue(Of NetFile)(Files.DistinctBy(Function(a) a.LocalPath))
|
||||
Files = New ConcurrentQueue(Of NetFile)(Files.DistinctBy(Function(a) PathUtils.ForCompare(a.LocalPath).Lower()))
|
||||
'设置剩余文件数
|
||||
SyncLock FileRemainLock
|
||||
FileRemain += Files.Where(Function(f) f.State <> NetState.Finished).Count
|
||||
@@ -1421,7 +1421,7 @@ FinishExCatch:
|
||||
Next
|
||||
If Not File.HasAvailableSource() Then Throw New ArgumentException("输入的下载链接不正确!")
|
||||
File.LocalPath = File.LocalPath.Replace("/", "\")
|
||||
If Not File.LocalPath.Lower.Contains(":\") Then Throw New ArgumentException("输入的本地文件地址不正确:" & File.LocalPath)
|
||||
If Not File.LocalPath.Contains(":\") Then Throw New ArgumentException("输入的本地文件地址不正确:" & File.LocalPath)
|
||||
If File.LocalPath.EndsWithF("\") Then Throw New ArgumentException("请输入含文件名的完整文件路径:" & File.LocalPath)
|
||||
DirectoryUtils.Create(PathUtils.RemoveLastPart(File.LocalPath)) '创建目标文件夹
|
||||
Next
|
||||
@@ -1519,7 +1519,7 @@ FinishExCatch:
|
||||
Select(Function(FolderName) (FolderName, File.LocalPath.IndexOfF(FolderName, True))).
|
||||
Where(Function(kv) kv.Item2 >= 0).ToList
|
||||
If Not TypeIndexes.Any Then
|
||||
If File.LocalName.EndsWithF(".jar") Then
|
||||
If PathUtils.GetExtension(File.LocalName) = "jar" Then
|
||||
TypeIndexes.Add(("\versions\", 1)) '总是对 jar 进行版本文件检查,以包括另存为 jar 的情况
|
||||
Else
|
||||
Return Nothing
|
||||
@@ -1547,7 +1547,7 @@ FinishExCatch:
|
||||
Case "versions\"
|
||||
'版本 jar 或 json:查找 MC 文件夹下的各个版本文件夹
|
||||
For Each VersionFolder In VersionFolders
|
||||
For Each Candidate In DirectoryUtils.EnumerateFiles(VersionFolder, searchPattern:="*." & PathUtils.GetLastPart(File.LocalPath).AfterLast(".").Lower)
|
||||
For Each Candidate In DirectoryUtils.EnumerateFiles(VersionFolder, searchPattern:="*." & PathUtils.GetExtension(File.LocalPath))
|
||||
If CheckCandidate(Candidate, File.Check) Then Return Candidate
|
||||
Next
|
||||
Next
|
||||
|
||||
@@ -382,7 +382,7 @@ Public Class ValidateFolderPath
|
||||
Public Overrides Function Validate(Str As String) As String
|
||||
'去除尾部斜线,统一为 \
|
||||
Str = Str.Replace("/", "\")
|
||||
If Not Str.TrimEnd("\").EndsWithF(":") Then Str = Str.TrimEnd("\")
|
||||
If Not PathUtils.RemoveSlashSuffix(Str).EndsWithF(":") Then Str = PathUtils.RemoveSlashSuffix(Str)
|
||||
'检查是否为空
|
||||
Dim LengthCheck As String = New ValidateNullOrWhiteSpace().Validate(Str)
|
||||
If LengthCheck <> "" Then Return LengthCheck
|
||||
|
||||
Reference in New Issue
Block a user