Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@quilime
Created November 16, 2014 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quilime/975b1dca8268008c6b0a to your computer and use it in GitHub Desktop.
Save quilime/975b1dca8268008c6b0a to your computer and use it in GitHub Desktop.
<?php
function get_patches($dir){
global $c, $inc, $offset_left, $offset_top;
$dir_array = [];
$inc = 0;
$path = realpath($dir);
//$dirs = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
$dirs = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
$objects = new RecursiveIteratorIterator($dirs, RecursiveIteratorIterator::SELF_FIRST);
$section = basename($dir);
// script_header($section);
// filter unique paths: loop through all objects and store names in dir_array
foreach($objects as $name => $object){
if($object->isDir() && $object->getBasename()[0] != '.'){
array_push($dir_array, $name);
}
}
array_push($dir_array, $dir);
print_r($dir_array);
//check for banner/badges for each folder as a recursive process with filtered array of paths
for($i = 0; $i < count($dir_array); $i++){
foreach(new DirectoryIterator($dir_array[$i]) as $file) {
$basename = $file->getBasename();
if($file->isFile() && $basename != '.') {
echo 'basename: ' . $basename . "\n";
echo 'path: ' . $file->getPath() . "\n";
}
}
}
}
$result = get_patches('CNMAT-MMJ-Depot-master/examples/demos/');
print_r($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment