diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
commit | e735ad6710a82604a206ad29f6cbcdd7dc4b024c (patch) | |
tree | 5fe8eebbb7a2bff20bb71bd2368955356979e0a2 /lib/buffer.c | |
parent | sync (diff) | |
download | lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.gz lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.bz2 lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.zip |
refactor and add su
Diffstat (limited to 'lib/buffer.c')
-rw-r--r-- | lib/buffer.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/buffer.c b/lib/buffer.c index 2bee94b..cad286a 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -1,5 +1,4 @@ -#include "buffer.h" -#include "convert.h" +#include "lslib.h" #include <limits.h> #include <string.h> @@ -58,3 +57,21 @@ void pop_path_buffer_2(int i) { bool is_dot_dir(const char* path) { return streql(path, ".") || streql(path, ".."); } + +const char* get_last_component(const char* path) { + const char* last; + char c; + + last = NULL; + + while (c = *path, true) { + if (c == '\\') { + last = path; + } else if (c == '\0') { + break; + } + path++; + } + + return last; +} |