Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r--source/blender/blenlib/intern/path_util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 111b530a527..18acbca00a1 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1685,6 +1685,24 @@ void BLI_split_file_part(const char *string, char *file, const size_t filelen)
}
/**
+ * Returns a pointer to the last extension (e.g. the position of the last period).
+ * Returns NULL if there is no extension.
+ */
+const char *BLI_path_extension(const char *filepath)
+{
+ const char *extension = strrchr(filepath, '.');
+ if (extension == NULL) {
+ return NULL;
+ }
+ if (BLI_first_slash(extension) != NULL) {
+ /* There is a path separator in the extension, so the '.' was found in a
+ * directory component and not in the filename. */
+ return NULL;
+ }
+ return extension;
+}
+
+/**
* Append a filename to a dir, ensuring slash separates.
*/
void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__restrict file)