Пример #1
0
 /**
  * Load all files in directory.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param string $path      Path to directory (must contain trailing slash)
  * @param bool   $recursive Load recursively
  *
  * @return bool
  */
 function load_directory($path, $recursive = true)
 {
     // Make sure directory exists
     if (!file_exists($path)) {
         return false;
     }
     // Scan directory
     $directory = scandir($path);
     $directory = array_slice($directory, 2);
     // No files found in directory
     if (empty($directory)) {
         return false;
     }
     // Parse directory
     foreach ($directory as $item) {
         // If item is a directory and recursive is false.
         // We'll simply skip the directory and move on.
         if (is_dir($path . $item) && !$recursive) {
             continue;
         }
         if (is_dir($path . $item)) {
             // Load directory
             load_directory($path . $item . '/');
         } else {
             // Load file
             include $path . $item;
         }
     }
     return true;
 }
function load_directory($startdir = "./", $searchSubdirs = 1, $directoriesonly = 0, $maxlevel = "all", $level = 1)
{
    //list the directory/file names that you want to ignore
    $ignoredDirectory[] = ".";
    $ignoredDirectory[] = "..";
    $ignoredDirectory[] = ".svn";
    global $directorylist;
    //initialize global array
    if (is_dir($startdir)) {
        if ($dh = opendir($startdir)) {
            while (($file = readdir($dh)) !== false) {
                if (!(array_search($file, $ignoredDirectory) > -1)) {
                    if (is_dir($startdir . "/" . $file)) {
                        //build your directory array however you choose;
                        //add other file details that you want.
                        $directorylist[$startdir . $file]['level'] = $level;
                        $directorylist[$startdir . $file]['dir'] = "DIR";
                        $directorylist[$startdir . $file]['size'] = filesize($startdir . "/" . $file);
                        $directorylist[$startdir . $file]['nombre'] = $file;
                        $directorylist[$startdir . $file]['ruta'] = $startdir;
                        if ($searchSubdirs) {
                            if ($maxlevel == "all" or $maxlevel > $level) {
                                load_directory($startdir . "/" . $file, $searchSubdirs, $directoriesonly, $maxlevel, $level + 1);
                            }
                        }
                    } else {
                        if (!$directoriesonly) {
                            //if you want to include files; build your file array
                            //however you choose; add other file details that you want.
                            $directorylist[$startdir . $file]['level'] = $level;
                            $directorylist[$startdir . $file]['dir'] = "FILE";
                            $directorylist[$startdir . $file]['size'] = filesize($startdir . "/" . $file);
                            $directorylist[$startdir . $file]['nombre'] = $file;
                            $directorylist[$startdir . $file]['ruta'] = $startdir;
                        }
                    }
                }
            }
            closedir($dh);
        }
    }
    return $directorylist;
}
Пример #3
0
 /**
  * Run database migrations and seeders.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return void
  */
 protected final function runDatabaseMigrationsAndSeeders()
 {
     // Ask to migrate the database,
     // if we've copied any migration files to the application.
     if (!empty($this->migrations) && $this->getCommand()->confirm('Do you wish to migrate your database?', true)) {
         try {
             $this->getCommand()->call('migrate');
         } catch (Exception $e) {
             $this->getCommand()->error(sprintf('Could not migrate your database. Reason: %s', $e->getMessage()));
         }
     }
     // Before we ask user to seed the database
     // we need to have look in the $seeders array
     // to remove folders from the array
     $seeders = [];
     foreach ($this->seeders as $seeder) {
         if (is_dir(base_path($seeder))) {
             continue;
         }
         $seeders[] = $seeder;
     }
     // Ask to seed the database,
     // if we've copied any migration files to the application.
     if (!empty($seeders) && $this->getCommand()->confirm('Do you wish to seed your database?', true)) {
         // Load seeders directory so new seeders are available
         load_directory($this->getInstaller()->getBasePath('database/seeds/'));
         // Run package seeders
         foreach ($seeders as $seeder) {
             try {
                 $seederFilename = substr($seeder, strrpos($seeder, '/') + 1);
                 $this->getCommand()->call('db:seed', ['--class' => substr($seederFilename, 0, strrpos($seederFilename, '.'))]);
             } catch (Exception $e) {
                 $this->getCommand()->error(sprintf('Could not seed database. Reason: %s', $e->getMessage()));
             }
         }
     }
 }
Пример #4
0
}
function load_directory($path)
{
    if (is_dir($path)) {
        $dir = directory_map($path);
        return dir_merge($path, $dir);
    } else {
        return $path;
    }
}
$files = array_filter($files, 'remove_nulls');
$files = array_map('remove_spaces', $files);
$allFiles = array();
foreach ($files as $item) {
    if (is_dir($item)) {
        $allFiles = array_merge($allFiles, load_directory($item));
    } else {
        if (is_file($item)) {
            array_push($allFiles, $item);
        }
    }
}
//packing data
$data = array();
foreach ($allFiles as $item) {
    $data[$item] = read_file($item);
}
$package->name = $ci->input->post('pluginName');
$package->version = $ci->input->post('version');
$package->author = $ci->input->post('author');
$package->website = $ci->input->post('website');
Пример #5
0
function load_directory($dir, &$lines, $directive)
{
    if (file_exists($dir) == True and is_dir($dir) == True) {
        term_echo("load_directory: \"{$dir}\" found");
        $handle = opendir($dir);
        while (($file = readdir($handle)) !== False) {
            if ($file == "." or $file == "..") {
                continue;
            }
            $fullname = $dir . "/" . $file;
            if (is_dir($fullname) == True) {
                load_directory($fullname, $lines, $directive);
            } else {
                load_include($fullname, $lines, $directive);
            }
        }
        closedir($handle);
    } else {
        term_echo("load_directory: \"{$dir}\" not found");
    }
}
Пример #6
0
 /**
  * Load project API routes.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return void
  */
 private function loadRoutes()
 {
     // Generate routes directory path
     $routesDirectory = base_path('project/Routes/Api/');
     // Make sure our directory exists
     if (!file_exists($routesDirectory)) {
         return;
     }
     // Load routes in directory
     load_directory($routesDirectory);
 }
Пример #7
0
 /**
  * Autoload files and directories.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return void
  */
 protected function autoloadFilesAndDirectories()
 {
     // Load files/directories from config file
     $autoload = config('nodes.autoload', null);
     if (empty($autoload)) {
         return;
     }
     foreach ($autoload as $item) {
         // Retrieve full path of item
         $itemPath = base_path($item);
         // If item doesn't exist, we'll skip it.
         if (!file_exists($itemPath)) {
             continue;
         }
         // If item is a file, we'll load it.
         //
         // If item is a directory, we'll recursively
         // go through it and load all the files we find.
         if (is_file($itemPath)) {
             include $itemPath;
         } else {
             load_directory($itemPath);
         }
     }
 }