I have a file:// URI that corresponds to a directory that I need to create (using svn mkdir, therefore file:create-dir() is not an option here) if it doesn’t exist. Calling file:path-to-native() on it results in a file:not-found error. Is there a fundamental reason why the file needs to exist before transforming its URI into the OS-native representation? Using BaseX 10.7.
Gerrit
On Mon, 2024-04-22 at 08:00 +0200, Imsieke, Gerrit, le-tex wrote:
I have a file:// URI that corresponds to a directory that I need to create (using svn mkdir, therefore file:create-dir() is not an option here) if it doesn’t exist. Calling file:path-to-native() on it results in a file:not-found error. Is there a fundamental reason why the file needs to exist before transforming its URI into the OS- native representation? Using BaseX 10.7.
First, as you prolly saw, the spec does say it's an error if the file does not exist.
Second, it behaves differently if it points to a directory than if it points to a file, and symbolic links are resolved.
But i agree there doesn't seem a reason for it to be an error if the file isn't there, except to the extent that it doesn't know whether to append the file separator for a directory...
It’s documented as non-deterministic, though, so that's OK.
liam
[1] http://expath.org/spec/file#fn.path-to-native
Hi Gerrit,
If you don’t need the canonical path to a file resource on the file system, file:resolve-path may be the better choice. It can be used for both file URIs and local (relative or absolute) paths.
Hope this helps, Christian
On Mon, Apr 22, 2024 at 8:00 AM Imsieke, Gerrit, le-tex < gerrit.imsieke@le-tex.de> wrote:
I have a file:// URI that corresponds to a directory that I need to create (using svn mkdir, therefore file:create-dir() is not an option here) if it doesn’t exist. Calling file:path-to-native() on it results in a file:not-found error. Is there a fundamental reason why the file needs to exist before transforming its URI into the OS-native representation? Using BaseX 10.7.
Gerrit
Thank you Christian, I should have read the description of file:resolve-path(). It does exactly what I need.
Gerrit
On 22.04.2024 10:59, Christian Grün wrote:
Hi Gerrit,
If you don’t need the canonical path to a file resource on the file system, file:resolve-path may be the better choice. It can be used for both file URIs and local (relative or absolute) paths.
Hope this helps, Christian
On Mon, Apr 22, 2024 at 8:00 AM Imsieke, Gerrit, le-tex <gerrit.imsieke@le-tex.de mailto:gerrit.imsieke@le-tex.de> wrote:
I have a file:// URI that corresponds to a directory that I need to create (using svn mkdir, therefore file:create-dir() is not an option here) if it doesn’t exist. Calling file:path-to-native() on it results in a file:not-found error. Is there a fundamental reason why the file needs to exist before transforming its URI into the OS-native representation? Using BaseX 10.7. Gerrit
basex-talk@mailman.uni-konstanz.de