file:current-dir(), file:path-to-native()
Friday, 8 August 2025 · 3 messages
HR
Hans-Juergen Rennau8 Aug 2025 11:40 #
Dear BaseX people,
I noticed a peculiar behaviour of
file:current-dir() on a Windows system.
file:current-dir()
=>
C:\program files\Oxygen XML Editor 25\
file:path-to-native(current-dir()
=>
C:\Program Files\Oxygen XML Editor 25\
Note the difference: "Program Files" vs. "programfiles".
Is this intended? Would one not expect that any path returned by a file:* function *is* native? (Remark: the difference of case can become very important when constructing relative paths.)
Kind regards,
Hans-Jürgen
:
On the system in question, the folder "Program Files" is mapped to "programme" (I do not know the reasons.
cuCG
Christian Grün8 Aug 2025 11:52 #
Hi Hans-Jürgen,
Quoted text · Hans-Juergen Rennau · 1 line
> Is this intended? Would one not expect that any path returned by a file:* function *is* native?
(Remark: the difference of case can become very important when constructing relative paths.)
The exact behavior of the file functions depend a lot on the operating system and local environment: As Windows ignores case, both "C:\a" and "C:\A" point to the same resource. It is only
file:path-to-native (or Path.toRealPath, in Java) that retrieves the exact writing from the file system.
If we enforced all paths to be “native”, every function that references a nonexisting path would raise an error.
If you need a canonical path representation, however, and if you know that your files exist, it is best to always call file:path-to-native (it will also give you a good chance to think about the handling of symbolic links ;·).
Hope this helps,
ChristianQuoted text · Hans-Juergen Rennau · 20 lines
Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Freitag, 8. August 2025 11:40 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] file:current-dir(), file:path-to-native() Dear BaseX people, I noticed a peculiar behaviour of file:current-dir() on a Windows system. file:current-dir() => C:\program files\Oxygen XML Editor 25\ file:path-to-native(current-dir() => C:\Program Files\Oxygen XML Editor 25\ Note the difference: "Program Files" vs. "programfiles". Is this intended? Would one not expect that any path returned by a file:* function *is* native? (Remark: the difference of case can become very important when constructing relative paths.) Kind regards, Hans-Jürgen : On the system in question, the folder "Program Files" is mapped to "programme" (I do not know the reasons. cu
HR
Hans-Juergen Rennau8 Aug 2025 12:08 #
Great! Thank you, Christian, for the explanation and the advice. This is good to know, and I will do as you propose.
Kind regards,
Hans-Jürgen
Am Freitag, 8. August 2025 um 11:52:51 MESZ hat Christian Grün <cg at basex.org> Folgendes geschrieben:
Hi Hans-Jürgen,
Quoted text · Christian Grün · 1 line
> Is this intended? Would one not expect that any path returned by a file:* function *is* native?
(Remark: the difference of case can become very important when constructing relative paths.)
The exact behavior of the file functions depend a lot on the operating system and local environment: As Windows ignores case, both "C:\a" and "C:\A" point to the same resource. It is only
file:path-to-native (or Path.toRealPath, in Java) that retrieves the exact writing from the file system.
If we enforced all paths to be “native”, every function that references a nonexisting path would raise an error.
If you need a canonical path representation, however, and if you know that your files exist, it is best to always call file:path-to-native (it will also give you a good chance to think about the handling of symbolic links ;·).
Hope this helps,
ChristianQuoted text · Hans-Juergen Rennau · 20 lines
Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Freitag, 8. August 2025 11:40 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] file:current-dir(), file:path-to-native() Dear BaseX people, I noticed a peculiar behaviour of file:current-dir() on a Windows system. file:current-dir() => C:\program files\Oxygen XML Editor 25\ file:path-to-native(current-dir() => C:\Program Files\Oxygen XML Editor 25\ Note the difference: "Program Files" vs. "programfiles". Is this intended? Would one not expect that any path returned by a file:* function *is* native? (Remark: the difference of case can become very important when constructing relative paths.) Kind regards, Hans-Jürgen : On the system in question, the folder "Program Files" is mapped to "programme" (I do not know the reasons. cu
Written for BaseX 12.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery