likle / cwalk

Path library for C/C++. Cross-Platform for Linux, FreeBSD, Windows and MacOS. Supports UNIX and Windows path styles on those platforms.
https://likle.github.io/cwalk/
MIT License
253 stars 40 forks source link

Made length parameter optional for cwk_path_get_basename #27

Closed noodlecollie closed 2 years ago

noodlecollie commented 2 years ago

I wanted to make use of cwk_path_get_basename() for a project of mine in order to strip the directory chain from a path and just keep the file name and extension. The function call works for this, but I had to provide a length variable even though I didn't need to use the length.

This PR modifies the function slightly so that length can safely be passed as NULL if the caller does not need it. I didn't think this change would be worth adding to other functions, as the purpose of the others is generally to extract a segment from the middle of the path, rather than trimming it.

likle commented 2 years ago

Hi @noodlecollie ! Thanks for your PR, it's much better like this :)