The test result with only 42 lines of code:
$ ./Path TEST1: /a/b/c/d/e.ext TOT DIR: 4 a/b/c/d ARCH:e.ext PATH:/a/b/c/d/e.ext TEST2: /a/b//c/e.ext TOT DIR: 3 a/b/c ARCH:e.ext PATH:/a/b/c/e.ext TEST3: /a/b///c/e.ext TOT DIR: 3 a/b/c ARCH:e.ext PATH:/a/b/c/e.ext TEST4: /a/b/./c/d/e/../../f/g/e.ext TOT DIR: 5 a/b/c/f/g ARCH:e.ext PATH:/a/b/c/f/g/e.ext TEST5: /a/b/c////d/e/f/g/../../../../../../../../../../../h/e.ext TOT DIR: 1 h ARCH:e.ext PATH:/h/e.ext SETBASE: x/y/z TEST6: /a/b/c////d/e/f/g/../../../../../../../../../../../h/e.ext TOT DIR: 1 h ARCH:e.ext PATH:/x/y/z/h/e.ext
Work with root directory or relative directory.
Trace link without leaving the root directory.
Open the file according to arranged mode.
I have solved it in a simple way, and much shorter than the previous time.
I have designed it not to leave the root directory in each workspace. That way I can make each user have different work areas at the same time.