I studied a lot of this topic, but could not get anything significant. By normalizing / canonicalize, I want to remove all "..", ".", Multiple slashes, etc. From the file path and get a simple absolute path. eg
"/rootdir/dir1/dir2/dir3/../././././dir4//////////" before "/ RootDir / dir1 / dir2 / dir4"
On Windows, I have GetFullPathName () , and I can get the name canonical filepath, but for Linux I can’t find an API that can do the same job for me, realpath () exists, but even realpath () requires the path to the file was present in the file system in order to be able to output a normalized path , for example. if the path / rootdir / dir 1 / dir2 / dir4 is not in the file system - realpath () will cause an error with the above complex input of the file path. Is there a way by which you can get a normalized path to a file , even if it does not exist on the file system ?
source
share