Surely it is possible. It is not clear whether it is desirable though as it breaks compatibility with Unix-like systems. I think we can better wait until Microsoft sees the light and implements sensible file system semantics. They seem to be moving slowly in that direction (as well as towards UTF-8 which would allow us finally to exchange text files transparently when they contain non-ASCI characters).
Unix files systems don’t have file or directory paths of this type,
thats Windows specific, and counts as an absolute path on Windows,
or a relative indexed path, indexed by drive letter:
<drive>:<path>
So basically you should be able to distinguish chdir('c:') from chdir('c:/'), like node.exe can do:
Its consistent with that an empty path is a relative path, so its actually
a two step process. Change the active drive, and then update the working
directory. But updating via empty path in the case C: results in the same
working directory as before. On the other hand in the case C:/ the
path is not empty, it is /, so that one gets indeed a working directory
update of the drive C:. But I just see node.exe might have a glitch,
or maybe this is indented? It doesn’t normalize the drive letter to
upper case as seen in the second example above.
As a consequence, being at c: the code below would no longer work, ending up in c:/work rather than c:. Note that chdir/1 is just a commandline shortcut to working_directory/2.
setup_call_cleanup(
working_directory(Old, 'c:/work'),
do something,
working_directory(_, Old)).
It is advised to change the working directory at most once during program initialization and do not touch is afterwards because the working directory is shared between the threads. Some systems nowadays implement a thread-specific working directory, but not all AFAIK
I see. That would make c: distinct from c:/ and the working directory returning the root of a drive as x:/, so you can go back there. I doubt I like that. I’d rather have a win_* predicate to change the current drive. I don’t see much value in it though. What would you want to use it for?