# get_proper_path

Definition: | string path = get_proper_path(sequence filepath, object rootdir=0)
Description: | Return the fully qualified absolute path and file name of the specified file.
pwa/p2js: | Implemented in p2js.js as a null function, mainly so that builtins\file_utils.e can be auto-transpiled.
Comments: | The root directory is only used when filepath is relative rather than absolute. If no root directory is provided, and one is needed, current_dir() is used. Both forwardslash ('/') and backslash ('\\') are supported on all platforms, and converted appropriately in the output. Should work equally well for files and directories. The result has the correct file separators for the operating system and, on Windows, the exact case of any existing files and directories, the intention being that your application will not behave as if C:\Downloads\test.txt and C:\downloadS/TEST.TXT are two different files, and things like find() work, without needing to resort to a loop and lower(x)=lower(y) on each element. The result should not be taken as confirmation of the actual existence of a file or directory.
Examples: |
    ?get_proper_path(`C:\Downloads\dEad\TesT.txt`)  -- `C:\Downloads\dead\test.txt`         (TesT on p2js)
    ?get_proper_path(`C:\downloadS\deAd\TEST.TXT`)  -- `C:\Downloads\dead\test.txt`         (TEST on p2js)
    ?get_proper_path(`C:\prOgram Files (x86)\Phix`) -- `C:\Program Files (x86)\Phix`            ...
    ?get_proper_path(`C:\bYetHost\EDITA`)           -- `C:\byethost\edita`
    ?get_proper_path(`C:\UseRs\`)                   -- `C:\Users\`
    ?get_proper_path("p.exw")                       -- `C:\Program Files (x86)\Phix\p.exw`  (`p.exw` on p2js)
    ?get_proper_path("demo")                        -- `C:\Program Files (x86)\Phix\demo`   ('demo'  on p2js)
    ?get_proper_path(`demo\`)                       -- `C:\Program Files (x86)\Phix\demo\`  ('demo\' on p2js)
Implementation: | See builtins\pgetpath.e (an autoinclude) for details of the actual implementation.
See Also: | current_dir
Technicalia | The filepath can be a string such as ``C:\`` or the equivalent dword-sequence which is `{'C',':','\\'}` - the latter proved necessary in Edita, especially when handling unicode and in particular UTF16 files. Of course the result is fairly meaningless if the the specified file or path does not exist, but if you can open the input the same should always be true for the output (after closing the other). The point of the routine is to create a consistent path/name in terms of short->long filenames and actual upper/lower case, so that for example your application does not think that C:\PROGRA~2\PHIX\P.EXE and C:\Program Files (x86)\Phix\p.exe are two different files, in fact passing the former in should yield the latter out, as long as that "PROGRA~2" short form matches what is shown when you run "dir /X".