forked from crftwr/cfiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfiler_checkdir.py
48 lines (34 loc) · 1.08 KB
/
cfiler_checkdir.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import time
import threading
import ckit
import cfiler_native
class CheckDirThread( threading.Thread ):
def __init__( self, path ):
threading.Thread.__init__(self)
self.setName(path)
self.path = path
self.cancel_requested = False
self.changed = False
self.check_dir = None
def run(self):
ckit.setBlockDetector()
try:
self.check_dir = cfiler_native.CheckDir(self.path)
except WindowsError:
return
while True:
if self.cancel_requested : break
self.check_dir.wait()
self.changed = True
# 最短でもでも3秒間隔
for i in range(30):
if self.cancel_requested : break
time.sleep(0.1)
def cancel(self):
self.cancel_requested = True
if self.check_dir:
self.check_dir.close()
def isChanged(self):
ret = self.changed
self.changed = False
return ret