@@ -24,7 +24,7 @@ public function __construct(Lfm $lfm = null)
2424 public function __get ($ var_name )
2525 {
2626 if ($ var_name == 'storage ' ) {
27- return $ this ->helper ->getStorage ($ this ->path ('storage ' ));
27+ return $ this ->helper ->getStorage ($ this ->path ('url ' ));
2828 }
2929 }
3030
@@ -63,7 +63,7 @@ public function path($type = 'storage')
6363 {
6464 if ($ type == 'working_dir ' ) {
6565 // working directory: /{user_slug}
66- return $ this ->normalizeWorkingDir ();
66+ return $ this ->translateToLfmPath ( $ this -> normalizeWorkingDir () );
6767 } elseif ($ type == 'url ' ) {
6868 // storage: files/{user_slug}
6969 return $ this ->helper ->getCategoryName () . $ this ->path ('working_dir ' );
@@ -78,6 +78,11 @@ public function path($type = 'storage')
7878 }
7979 }
8080
81+ public function translateToLfmPath ($ path )
82+ {
83+ return str_replace ($ this ->helper ->ds (), Lfm::DS , $ path );
84+ }
85+
8186 public function translateToOsPath ($ path )
8287 {
8388 return str_replace (Lfm::DS , $ this ->helper ->ds (), $ path );
@@ -142,6 +147,25 @@ public function createFolder()
142147 $ this ->storage ->makeDirectory (0777 , true , true );
143148 }
144149
150+ public function isDirectory ()
151+ {
152+ $ working_dir = $ this ->path ('working_dir ' );
153+ $ parent_dir = substr ($ working_dir , 0 , strrpos ($ working_dir , '/ ' ));
154+
155+ $ parent_path = clone $ this ;
156+ $ parent_path ->dir ($ parent_dir )->setName (null );
157+
158+ $ directories = $ parent_path ->directories ();
159+
160+ $ that = $ this ;
161+
162+ $ directories = array_map (function ($ directory_path ) use ($ that ) {
163+ return $ this ->translateToLfmPath ($ directory_path );
164+ }, $ directories );
165+
166+ return in_array ($ this ->path ('url ' ), $ directories );
167+ }
168+
145169 /**
146170 * Check a folder and its subfolders is empty or not.
147171 *
0 commit comments