From 2f6f601d13e9ebf839e37d976918edc34e99fd69 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 26 Jul 2020 06:43:33 +0800 Subject: [PATCH] 1 --- CheckFile.go | 21 ++++----------------- linuxwin/linux.go | 5 ----- linuxwin/win.go | 4 ---- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/CheckFile.go b/CheckFile.go index 9a8842e..ee88871 100644 --- a/CheckFile.go +++ b/CheckFile.go @@ -1,7 +1,6 @@ package part import ( - "sync" "fmt" "time" "runtime" @@ -9,12 +8,10 @@ import ( "syscall" "errors" "os" - "io/ioutil" - - "github.com/qydysky/part/linuxwin" + "io/ioutil" ) -type checkfile struct {sync.Mutex} +type checkfile struct {} func Checkfile() *checkfile{ return &checkfile{} @@ -102,10 +99,8 @@ func (this *checkfile) Check(checkFile,checkDir,SplitString string) bool { } func (this *checkfile) IsExist(f string) bool { - this.Lock() - defer this.Unlock() - - return Ppart.PIsExist(f) + _, err := os.Stat(f) + return err == nil || os.IsExist(err) } func (this *checkfile) IsOpen(f string) bool { @@ -116,8 +111,6 @@ func (this *checkfile) IsOpen(f string) bool { } func (this *checkfile) Checkfile(src string)(string,error){ - this.Lock() - defer this.Unlock() str,err:=this.GetAllFile(src) @@ -128,8 +121,6 @@ func (this *checkfile) Checkfile(src string)(string,error){ } func (this *checkfile) GetAllFile(pathname string) (string,error) { - this.Lock() - defer this.Unlock() var returnVal string = "" @@ -147,8 +138,6 @@ func (this *checkfile) GetAllFile(pathname string) (string,error) { } func (this *checkfile) GetFileSize(path string) int64 { - this.Lock() - defer this.Unlock() if !this.IsExist(path) { return 0 @@ -222,8 +211,6 @@ func (this *checkfile) CheckList(checkFile,checkDir,SplitString string)bool{ } func (this *checkfile) GetFileModTime(path string) (error,int64) { - this.Lock() - defer this.Unlock() f, err := os.Open(path) if err != nil { diff --git a/linuxwin/linux.go b/linuxwin/linux.go index 8aea6e7..c25f7ea 100755 --- a/linuxwin/linux.go +++ b/linuxwin/linux.go @@ -58,8 +58,3 @@ func PProxy(s, pacUrl string){ PRun(true,"kwriteconfig5","--file","kioslaverc","--group","'Proxy Settings'","--key","Proxy Config Script","\""+pacUrl+"\""); } } - -func PIsExist(f string) bool{ - _, err := os.Stat(f) - return err == nil || os.IsExist(err) -} \ No newline at end of file diff --git a/linuxwin/win.go b/linuxwin/win.go index baaf17a..792f5e8 100755 --- a/linuxwin/win.go +++ b/linuxwin/win.go @@ -93,8 +93,4 @@ func Cdir()string{ dir, _ := os.Executable() exPath := filepath.Dir(dir) return exPath -} -func PIsExist(f string) bool{ - _, err := os.Stat(f) - return err == nil || os.IsExist(err) } \ No newline at end of file -- 2.39.2