func (this *checkfile) GetFileModTime(path string) (error,int64) {
+ if !this.IsExist(path) {return errors.New("not exist"),time.Now().Unix()}
+
f, err := os.Open(path)
if err != nil {
fmt.Println("open file error")
l.Lock()
defer l.Unlock()
- if e,t := Checkfile().GetFileModTime(filePath); e != nil || time.Now().Unix() - t <= lock_timeout {
- Logf().E(e.Error(),"or still alive")
- return errors.New("still alive")
+ if Checkfile().IsExist(filePath) {
+ if e,t := Checkfile().GetFileModTime(filePath); e != nil || time.Now().Unix() - t <= lock_timeout {
+ Logf().E(e.Error(),"or still alive")
+ return errors.New("still alive")
+ }
}
+
lock_file = filePath
lock_timeout = timeout
-
+
go func(){
for lock_file != "" {
File().FileWR(Filel{