DOCROOT -uploads --level1 ---leve2a ---leve2bFor example, the following code will throw an InvalidPathException.
$depth = 0; // a value of 2 will also throw the exception $config = array( 'basedir' => DOCROOT, 'use_locks' => true, ); $area = \File::factory($config); try { $dir = $area->read_dir('uploads', $depth); } catch(\InvalidPathException $e) { $dir = 'operation failed'; } Debug::dump($dir);No exception is thrown when var $depth is set to 1. Is it not intended for read_dir to be used recursively with areas?
<?php return array( 'areas' => array( 'my_area' => array( 'basedir' => DOCROOT, 'use_locks' => true, ), ), );
$area = \File::instance('my_area');At this point I get the following error twice:
Notice! ErrorException [ Notice ]: Object of class Fuel\Core\File_Area could not be converted to int COREPATH/classes/file.php @ line 49: 48: { 49: static::$areas[$name] = \File_Area::factory($config) + static::$base_area; 50: }Could this be related? Or, is it me again.
$basepath = DOCROOT.'uploads'; if (file_exists($basepath) and is_dir($basepath)) { \File::create_dir($basepath, 'level1'); } else { echo 'File not found or is not a directory'; }Fuel gives the following warning:
Warning! ErrorException [ Warning ]: mkdir(): No such file or directory COREPATH/classes/file.php @ line 155: 154: 155: return mkdir($new_dir, $chmod, $recursive); 156: }Sorry to be so much trouble.
$basepath = DOCROOT.'uploads'; // clean up for testing rmdir($basepath.DS.'level1'.DS.'level2'); rmdir($basepath.DS.'level1'); // create a dir and subdir $rval1 = \File::create_dir($basepath, 'level1'); $rval2 = \File::create_dir($basepath, 'level1'.DS.'level2'); Debug::dump($rval1, $rval2); // Results: Directories are successfully created and // both return values are true. Thanks, WanWizard. // create one file in each newly created directory $rval1 = \File::create($basepath.'level1', 'foo1.txt', 'contents of file foo1.txt'); $rval2 = \File::create($basepath.'level1'.DS.'level2', 'foo2.txt', 'contents of file foo2.txt'); Debug::dump($rval1, $rval2); // Results: Fuel throws an InvalidPathException. // [ Error ]: Invalid basepath, cannot create file at this location. // delete newly created directories and their contents recursively $rval1 = \File::delete_dir($basepath, true, false); Debug::dump($rval1); // Results: Returns true but directories still exist. // delete subdirectory 'level2' only $rval1 = \File::delete_dir($basepath.DS.'level1'.DS.'level2', true, true); Debug::dump($rval1); // Results: Returns true and subdirectory is successfully deleted.Again, thanks so much.
// create one file in each newly created directory $rval1 = \File::create($basepath.'level1', 'foo1.txt', 'contents of file foo1.txt'); $rval2 = \File::create($basepath.'level1'.DS.'level2', 'foo2.txt', 'contents of file foo2.txt');you're missing a directory separator here, as basepath doesn't end with one: $basepath.DS.'level1'. The recursive deletion problem was a bug, which is now fixed.
It looks like you're new here. If you want to get involved, click one of these buttons!