Skip to content

Commit

Permalink
Split function CheckFileDir
Browse files Browse the repository at this point in the history
  • Loading branch information
cjybyjk committed Jul 30, 2018
1 parent 424a61d commit 6ea9949
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' 方法是按如下所示使用“*”: :
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.1.5.0")>
<Assembly: AssemblyFileVersion("1.1.5.0")>
<Assembly: AssemblyVersion("1.1.6.0")>
<Assembly: AssemblyFileVersion("1.1.6.0")>
12 changes: 6 additions & 6 deletions frm_Main.vb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ Public Class frm_Main
outtmp = tmppath & "system\"

AppendTxtOut("I 临时文件目录: " & tmppath)
If CheckFileDir(tmppath) Then
If CheckDir(tmppath) Then
AppendTxtOut("I 清理临时文件" & vbCrLf)
My.Computer.FileSystem.DeleteDirectory(tmppath, FileIO.DeleteDirectoryOption.DeleteAllContents)
End If
CreatePath(tmppath)

AppendTxtOut("")

If Not CheckFileDir(txtSysImg.Text) Then
If Not CheckFile(txtSysImg.Text) Then
AppendTxtOut("E 错误: 未找到System镜像文件!")
GoTo exitD
End If
Expand All @@ -59,12 +59,12 @@ Public Class frm_Main
GoTo exitD
End If

If Not CheckFileDir(txtGSI.Text) Then
If Not CheckFile(txtGSI.Text) Then
AppendTxtOut("E 错误: 未找到GSI镜像文件!")
GoTo exitD
End If

If chkGetFileContext.Checked And (Not CheckFileDir(txtFileContexts.Text)) Then
If chkGetFileContext.Checked And (Not CheckFile(txtFileContexts.Text)) Then
AppendTxtOut("W 警告: 找不到自定义file_contexts! 将自动生成!")
chkGetFileContext.Checked = False
End If
Expand Down Expand Up @@ -108,7 +108,7 @@ Public Class frm_Main
My.Computer.FileSystem.CopyDirectory(syspath & "vendor", outtmp & "vendor")
End If

If CheckFileDir(txtPropFiles.Text) Then
If CheckFile(txtPropFiles.Text) Then
Dim flagNoRelpace As Boolean = False
AppendTxtOut("I 从proprietary-files.txt复制文件")
ConvertDosUnix(txtPropFiles.Text, tmppath & "proprietary-files.txt")
Expand All @@ -124,7 +124,7 @@ Public Class frm_Main
If Strings.Left(tmpLine, 1) = "-" Then tmpLine = Mid(2, tmpLine.Length - 1)
tmpLine = Replace(CutStr(tmpLine, ":", "|"), "/", "\")
If chkIsABDevice.Checked Then tmpLine = "system\" & tmpLine
If CheckFileDir(syspath & tmpLine) Then
If CheckFile(syspath & tmpLine) Then
CreatePath(outtmp & Mid(tmpLine, 1, InStrRev(tmpLine, "\")))
AppendTxtOut(" Copy: " & tmpLine)
If Not flagNoRelpace Then IO.File.Delete(outtmp & tmpLine)
Expand Down
8 changes: 6 additions & 2 deletions mod_FileIO.vb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Module mod_FileIO

Public Function CheckFileDir(ByVal strPath As String) As Boolean
CheckFileDir = (IO.Directory.Exists(strPath) Or IO.File.Exists(strPath)) And strPath.Length > 0
Public Function CheckFile(ByVal strPath As String) As Boolean
CheckFile = IO.File.Exists(strPath) And strPath.Length > 0
End Function

Public Function CheckDir(ByVal strPath As String) As Boolean
CheckDir = IO.Directory.Exists(strPath) And strPath.Length > 0
End Function

Public Sub FileDialog(ByVal strFilter As String, ByVal strTitle As String, ByRef txtbox As TextBox, Optional ByVal isOpen As Boolean = True)
Expand Down

0 comments on commit 6ea9949

Please sign in to comment.