File tree 3 files changed +51
-6
lines changed
3 files changed +51
-6
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,53 @@ Some useful filesystem util for php
9
9
- basic filesystem operation
10
10
- file read/write operation
11
11
- directory operation
12
- - file finder
12
+ - file modify watcher
13
+ - files finder
13
14
14
15
## Install
15
16
16
17
``` bash
17
18
composer require toolkit/fsutil
18
19
```
19
20
21
+ ## Usage
22
+
23
+ ### File Finder
24
+
25
+ ``` php
26
+ use Toolkit\FsUtil\FileFinder;
27
+
28
+ $finder = FileFinder::create()
29
+ ->files()
30
+ ->name('*.php')
31
+ // ->ignoreVCS(false)
32
+ // ->ignoreDotFiles(false)
33
+ // ->exclude('tmp')
34
+ ->notPath('tmp')
35
+ ->inDir(dirname(__DIR__));
36
+
37
+ foreach ($finder as $file) {
38
+ // var_dump($file);
39
+ echo "+ {$file->getPathname()}\n";
40
+ }
41
+ ```
42
+
43
+ ### Modify Watcher
44
+
45
+ ``` php
46
+ use Toolkit\FsUtil\ModifyWatcher;
47
+
48
+ $w = new ModifyWatcher();
49
+ $ret = $w
50
+ // ->setIdFile(__DIR__ . '/tmp/dir.id')
51
+ ->watch(dirname(__DIR__))
52
+ ->isChanged();
53
+
54
+ // d41d8cd98f00b204e9800998ecf8427e
55
+ // current file: ae4464472e898ba0bba8dc7302b157c0
56
+ var_dump($ret, $mw->getDirMd5(), $mw->getFileCounter());
57
+ ```
58
+
20
59
## License
21
60
22
61
MIT
Original file line number Diff line number Diff line change 12
12
require dirname (__DIR__ ) . '/test/boot.php ' ;
13
13
14
14
$ mw = new ModifyWatcher ();
15
- $ ret = $ mw// ->setIdFile(__DIR__ . '/tmp/dir.id')
16
- ->watch (dirname (__DIR__ ))->isChanged ();
15
+ $ ret = $ mw
16
+ // ->setIdFile(__DIR__ . '/tmp/dir.id')
17
+ ->watch (dirname (__DIR__ ))
18
+ ->isChanged ();
17
19
18
20
// d41d8cd98f00b204e9800998ecf8427e
19
21
// current file: ae4464472e898ba0bba8dc7302b157c0
Original file line number Diff line number Diff line change 13
13
// var_dump(fnmatch('.*', ".gitkeep"));die;
14
14
// var_dump(glob(__DIR__ . '/{t,T}ests', GLOB_BRACE | GLOB_ONLYDIR));
15
15
16
- $ finder = FileFinder::create ()->files ()->name ('*.php ' )// ->ignoreVCS(false)
16
+ $ finder = FileFinder::create ()
17
+ ->files ()
18
+ ->name ('*.php ' )
19
+ // ->ignoreVCS(false)
17
20
// ->ignoreDotFiles(false)
18
21
// ->exclude('tmp')
19
- ->notPath ('tmp ' )->inDir (dirname (__DIR__ ));
22
+ ->notPath ('tmp ' )
23
+ ->inDir (dirname (__DIR__ ));
20
24
21
25
foreach ($ finder as $ file ) {
22
- // var_dump($file);die;
26
+ // var_dump($file);
23
27
echo "+ {$ file ->getPathname ()}\n" ;
24
28
}
25
29
You can’t perform that action at this time.
0 commit comments