Skip to main content

News

  • The forums have now switched to ElkArte, an SMF fork which is more modern and maintained better!

Topic: General-purpose path parsing for C (Read 685 times) previous topic - next topic

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
General-purpose path parsing for C
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.
  • Last Edit: October 23, 2015, 01:27:01 am by Lord English
miniSphere 4.8.2 - Cell compiler - SSj debugger
Forum Thread | GitHub Repo