33namespace UniSharp \LaravelFilemanager ;
44
55use Illuminate \Support \Facades \Storage ;
6- use Unisharp \FileApi \FileApi ;
76
87class LfmStorageRepository implements RepositoryContract
98{
10- private $ disk_name ;
11-
129 private $ disk ;
1310
1411 private $ path ;
1512
1613 public function __construct ($ storage_path , $ disk_name )
1714 {
18- $ this ->disk_name = $ disk_name ;
19- $ this ->disk = Storage::disk ($ this ->disk_name );
15+ $ this ->disk = Storage::disk ($ disk_name );
2016 $ this ->path = $ storage_path ;
2117 }
2218
@@ -32,36 +28,6 @@ public function rootPath()
3228 return $ this ->disk ->getDriver ()->getAdapter ()->getPathPrefix ();
3329 }
3430
35- public function directories ()
36- {
37- return $ this ->disk ->directories ($ this ->path );
38- }
39-
40- public function files ()
41- {
42- return $ this ->disk ->files ($ this ->path );
43- }
44-
45- public function makeDirectory ()
46- {
47- return $ this ->disk ->makeDirectory ($ this ->path , 0777 , true , true );
48- }
49-
50- public function exists ()
51- {
52- return $ this ->disk ->exists ($ this ->path );
53- }
54-
55- public function getFile ()
56- {
57- return $ this ->disk ->get ($ this ->path );
58- }
59-
60- public function mimeType ()
61- {
62- return $ this ->disk ->mimeType ($ this ->path );
63- }
64-
6531 public function isDirectory ()
6632 {
6733 $ parent_path = substr ($ this ->path , 0 , strrpos ($ this ->path , '/ ' ));
@@ -76,24 +42,8 @@ public function move($new_lfm_path)
7642 return $ this ->disk ->move ($ this ->path , $ new_lfm_path ->path ('storage ' ));
7743 }
7844
79- /**
80- * Check a folder and its subfolders is empty or not.
81- *
82- * @param string $directory_path Real path of a directory.
83- * @return bool
84- */
85- public function directoryIsEmpty ()
86- {
87- return count ($ this ->disk ->allFiles ($ this ->path )) == 0 ;
88- }
89-
9045 public function save ($ file , $ new_filename )
9146 {
9247 $ this ->disk ->putFileAs ($ this ->path , $ file , $ new_filename );
9348 }
94-
95- private function insertSuffix ($ suffix , $ file_name )
96- {
97- return substr_replace ($ file_name , $ suffix , strpos ($ file_name , '. ' ), 0 );
98- }
9949}
0 commit comments