file:path-to-native() throws an error if its argument does not exist

Monday, 22 April 2024 · 4 messages
IL
Imsieke, Gerrit, le-tex22 Apr 2024 08:00 #
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
CG
Christian Grün22 Apr 2024 10:59 #
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
Quoted text · le-tex · 11 lines
On Mon, Apr 22, 2024 at 8:00 AM Imsieke, Gerrit, le-tex < gerrit.imsieke at 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 >
LQ
Liam R. E. Quinin reply to Imsieke, Gerrit, le-tex, 22 Apr 2024, 08:0022 Apr 2024 11:21 #
Quoted text · le-tex · 7 lines
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
Quoted text · Imsieke, Gerrit, le-tex · 1 line
>
-- Liam Quin, https://www.delightfulcomputing.com/ Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
IL
Imsieke, Gerrit, le-texin reply to Christian Grün, 22 Apr 2024, 10:5922 Apr 2024 11:58 #
Thank you Christian, I should have read the description of file:resolve-path(). It does exactly what I need. Gerrit
Quoted text · Christian Grün · 15 lines
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 at le-tex.de <mailto:gerrit.imsieke at 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 >

⚡Generated with XQuery