C5-8.3: how to get path to folder for file list?

Permalink
I need to list file names from a folder in a select dropdown box.

1. Should I use absolute or relative path to the folder?
2. How do I get that path in form.php before the block is added? The following only works in view.php but not in the form.php:
$pkg = \Concrete\Core\Package\Package::getByHandle('my_package_handle');
$path = $pkg->getRelativePath() . '/blocks/my_package/my_folder';
echo "Path: " . $path;

3. How can I get the file list? The following says: "scandir(/packages/my_package/blocks/my_package/my_folder/): failed to open dir: No such file or directory"
$files = array_diff(scandir($path), array('.', '..'));
echo $form->select('font', '', $files);

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
Got it. It's the

$path = $pkg->getPackagePath()

and

$files = glob($path . '*.ttf');