mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-21 18:19:19 +01:00
Added path_push_subdir function to path
This commit is contained in:
parent
1bdbfef8ac
commit
33a1729792
@ -88,16 +88,6 @@ bool path_is_root (path_t *path) {
|
||||
return (strcmp(path->root, "/") == 0);
|
||||
}
|
||||
|
||||
void path_push (path_t *path, char *string) {
|
||||
if (path->buffer[strlen(path->buffer) - 1] != '/') {
|
||||
path_append(path, "/");
|
||||
}
|
||||
if (string[0] == '/') {
|
||||
string += 1;
|
||||
}
|
||||
path_append(path, string);
|
||||
}
|
||||
|
||||
void path_pop (path_t *path) {
|
||||
if (path_is_root(path)) {
|
||||
return;
|
||||
@ -110,6 +100,25 @@ void path_pop (path_t *path) {
|
||||
}
|
||||
}
|
||||
|
||||
void path_push (path_t *path, char *string) {
|
||||
if (path->buffer[strlen(path->buffer) - 1] != '/') {
|
||||
path_append(path, "/");
|
||||
}
|
||||
if (string[0] == '/') {
|
||||
string += 1;
|
||||
}
|
||||
path_append(path, string);
|
||||
}
|
||||
|
||||
void path_push_subdir (path_t *path, char *string) {
|
||||
char *file = path_last_get(path);
|
||||
char *tmp = alloca(strlen(file) + 1);
|
||||
strcpy(tmp, file);
|
||||
path_pop(path);
|
||||
path_push(path, string);
|
||||
path_push(path, tmp);
|
||||
}
|
||||
|
||||
char *path_ext_get (path_t *path) {
|
||||
char *buffer = path_last_get(path);
|
||||
char *last_dot = strrchr(buffer, '.');
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/** @brief Path Structure */
|
||||
@ -26,8 +27,9 @@ path_t *path_clone_push (path_t *path, char *string);
|
||||
char *path_get (path_t *path);
|
||||
char *path_last_get (path_t *path);
|
||||
bool path_is_root (path_t *path);
|
||||
void path_push (path_t *path, char *string);
|
||||
void path_pop (path_t *path);
|
||||
void path_push (path_t *path, char *string);
|
||||
void path_push_subdir (path_t *path, char *string);
|
||||
char *path_ext_get (path_t *path);
|
||||
void path_ext_remove (path_t *path);
|
||||
void path_ext_replace (path_t *path, char *ext);
|
||||
|
Loading…
Reference in New Issue
Block a user