Spherical forums

Creations => Programming => Topic started by: Fat Cerberus on October 23, 2015, 01:24:04 am

Title: General-purpose path parsing for C
Post by: Fat Cerberus on October 23, 2015, 01:24:04 am
In the process of implementing Cell, I ended up writing this nifty set of path parsing functions along the way to replace the Allegro path API:
https://github.com/fatcerberus/minisphere/blob/master/src/path.c
https://github.com/fatcerberus/minisphere/blob/master/src/path.h

This turned into quite a robust set of routines, far beyond the limited set provided by Allegro.  You have your basic concatenation, of course (path_rebase(), path_cat()), and I also added routines for normalization (path_collapse()), canonization against the file system (path_resolve(), which can also relativize), even a recursive path_mkdir().  When you're done building the path, just do path_cstr(path_obj) to get the final path string for use with file system functions.

Feel free to use it. :)  Consider it MIT licensed like the rest of minisphere.