Adding support for custom file extension
Publish PHP Package / docker (push) Successful in 7s
Details
Publish PHP Package / docker (push) Successful in 7s
Details
This commit is contained in:
parent
32daca721f
commit
d228b43d1e
|
@ -100,18 +100,21 @@ function mtg_parse_meta(array $meta_srcs, $valid_tokens = null, $inc_path = null
|
|||
return $meta;
|
||||
}
|
||||
|
||||
function mtg_load_meta(mtgMetaInfo $meta, mtgIMetaInfoParser $meta_parser, string $dir_or_file)
|
||||
function mtg_load_meta(
|
||||
mtgMetaInfo $meta, mtgIMetaInfoParser $meta_parser,
|
||||
string $dir_or_file, string $extension = '.meta'
|
||||
)
|
||||
{
|
||||
$files = mtg_resolve_files($dir_or_file);
|
||||
$files = mtg_resolve_files($dir_or_file, $extension);
|
||||
foreach($files as $file)
|
||||
$meta_parser->parse($meta, $file);
|
||||
}
|
||||
|
||||
function mtg_resolve_files(string $dir_or_file) : array
|
||||
function mtg_resolve_files(string $dir_or_file, string $extension = '.meta') : array
|
||||
{
|
||||
$files = array();
|
||||
if(is_dir($dir_or_file))
|
||||
$files = mtg_find_meta_files($dir_or_file);
|
||||
$files = mtg_find_meta_files($dir_or_file, $extension);
|
||||
else if(is_file($dir_or_file))
|
||||
$files[] = $dir_or_file;
|
||||
else
|
||||
|
@ -119,7 +122,7 @@ function mtg_resolve_files(string $dir_or_file) : array
|
|||
return $files;
|
||||
}
|
||||
|
||||
function mtg_find_meta_files($dir)
|
||||
function mtg_find_meta_files($dir, $extension = '.meta')
|
||||
{
|
||||
$items = scandir($dir);
|
||||
if($items === false)
|
||||
|
@ -131,7 +134,7 @@ function mtg_find_meta_files($dir)
|
|||
if($item[0] == '.')
|
||||
continue;
|
||||
|
||||
if(strpos($item, ".meta") !== (strlen($item)-5))
|
||||
if(strpos($item, $extension) !== (strlen($item)-strlen($extension)))
|
||||
continue;
|
||||
|
||||
$file = $dir . '/' . $item;
|
||||
|
|
Loading…
Reference in New Issue