From 322d95add82220c5345b9e977066cf1903b85e82 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 18 Dec 2018 17:50:57 +0100 Subject: [PATCH] add Find_last_separator_unicode() function --- src/io.c | 18 +++++++++++++++++- src/io.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/io.c b/src/io.c index 559ad788..0af90718 100644 --- a/src/io.c +++ b/src/io.c @@ -258,7 +258,7 @@ char * Find_last_separator(const char * str) const char * position = NULL; for (; *str != '\0'; str++) if (*str == PATH_SEPARATOR[0] -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(WIN32) || *str == '/' #elif __AROS__ || *str == ':' @@ -267,6 +267,22 @@ char * Find_last_separator(const char * str) position = str; return (char *)position; } + +word * Find_last_separator_unicode(const word * str) +{ + const word * position = NULL; + for (; *str != 0; str++) + if (*str == (byte)PATH_SEPARATOR[0] +#if defined(__WIN32__) || defined(WIN32) + || *str == '/' +#elif __AROS__ + || *str == ':' +#endif + ) + position = str; + return (word *)position; +} + // Récupère la partie "nom de file seul" d'un chemin void Extract_filename(char *dest, const char *source) { diff --git a/src/io.h b/src/io.h index 7b328d8c..faf705fc 100644 --- a/src/io.h +++ b/src/io.h @@ -98,6 +98,9 @@ void Extract_path(char *dest, const char *source); /// Finds the rightmost path separator in a full filename. Used to separate directory from file. char * Find_last_separator(const char * str); +/// Finds the rightmost path separator in a full filename in unicode. Used to separate directory from file. +word * Find_last_separator_unicode(const word * str); + /// default path separator character #if defined(WIN32) || defined(__MINT__) #define PATH_SEPARATOR "\\"