whikloj / BagItTools

A PHP BagIt library
MIT License
11 stars 5 forks source link

Creation of bag with relative bag fails unless ./ prefix is used #26

Closed asmecher closed 3 years ago

asmecher commented 3 years ago

The following code fails:

$bag = Bag::create('my_bag_path');

...with...

PHP Fatal error:  Uncaught whikloj\BagItTools\Exceptions\FilesystemException: Unable to put contents to file /my_bag_path/bagit.txt in /.../vendor/whikloj/bagittools/src/BagUtils.php:283

It appears that my_bag_path is interpreted as an absolute path unless you prefix it with ./

I'm not sure if this is intentional, but in my opinion this library should behave like the PHP file functions, which would interpret my_bag_path as a relative path unless there is a / prefix in front.