Пример #1
0
                if (strcasecmp($a['text'], $b['text']) < 0) {
                    return -1;
                }
                if (strcasecmp($a['text'], $b['text']) > 0) {
                    return 1;
                }
            }
            if ($a['type'] == self::FOLDER && $b['type'] == self::FILE) {
                return -1;
            }
            if ($a['type'] == self::FILE && $b['type'] == self::FOLDER) {
                return 1;
            }
        });
        closedir($handle);
        return $structure;
    }
    private function GUID()
    {
        if (function_exists('com_create_guid') === true) {
            return trim(com_create_guid(), '{}');
        }
        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
    }
}
echo "Starting\n";
$rootFolder = isset($argv[1]) ? $argv[1] : getcwd();
$depth = isset($argv[2]) ? $argv[2] : 0;
$structure = new Structure();
$data = $structure->buildStructure($rootFolder, $depth);
die(json_encode($data));