Resolving dos paths....

for all subjects/topics not covered by the other forum categories
Post Reply
Prime
Posts: 2514
Joined: Sun May 31, 2009 11:52 pm
Contact:

Resolving dos paths....

Post by Prime » Sun Jul 23, 2017 4:08 pm

Posted here on the offchance someone can help....

Does anyone out there have source (or link to source) for resolving relative paths in an environment where I can't just call an OS library function***. I ideally want to convert something like "c:\test\..\test2\file.txt" into "c:\test2\file.txt" Yes I can probably write my own but why re-invent the wheel....

*** So telling me to use realpath or something like it will not help, this is on a bare metal microcontroller, with no OS, but using the FatFS library.

Cheers.

Phill.

User avatar
sweh
Posts: 1933
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Resolving dos paths....

Post by sweh » Sun Jul 30, 2017 1:49 pm

This may be overkill (it's designed for Unix and so handles symlinks, relative paths and the like), but it has ".." handling in it so you may be able to re-use the algorithm: http://www.scs.stanford.edu/histar/src/ ... realpath.c
Rgds
Stephen

Post Reply