Is there a POSIX syscall to resolve filesystem paths? I have the CWD for a path, as well as the path to a file from that CWD. I can’t use chdir to switch to the directory because I need to resolve paths from multiple threads simultaneously. I considered appending a / in between the CWD and the path, but for some reason it feels like that’s hacky. Is that the proper way to resolve relative paths?
Is there a POSIX syscall to resolve filesystem paths? I have the CWD for
Share
I think appending the
/should be sufficient in pretty much all situations – even with.,.., extra/s, or symlinks it should just do the right thing. If you really want to do this with the standard library, you can userealpath(3)to do path normalization but I don’t know of a way to do exactly what you want.