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:
authorCampbell Barton <ideasman42@gmail.com>2008-04-26 17:08:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-04-26 17:08:57 +0400
commitc8376869b1a521c903a6f8d1be49e48c2966df70 (patch)
tree6e3ff79d8b57303d5ea70a8211af78618cf40a78 /source/blender/blenlib/intern/util.c
parent19985ae918759780d3cf607a87b9fd110be518a0 (diff)
BLI_split_dirfile was being used in cases it should not have been,
Added BLI_split_dirfile_basic, that only splits the path into directory and file. without checking the dir exists or creating it, without changing the original string that is passed to it.
Diffstat (limited to 'source/blender/blenlib/intern/util.c')
-rw-r--r--source/blender/blenlib/intern/util.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index 623389a6ba2..c79f1b56f1d 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -1426,8 +1426,41 @@ int BLI_testextensie(const char *str, const char *ext)
return (retval);
}
+/*
+ * This is a simple version of BLI_split_dirfile that has the following advantages...
+ *
+ * Converts "/foo/bar.txt" to "/foo/" and "bar.txt"
+ * - wont change 'string'
+ * - wont create any directories
+ * - dosnt use CWD, or deal with relative paths.
+ * - Only fill's in *dir and *file when they are non NULL
+ * */
+void BLI_split_dirfile_basic(const char *string, char *dir, char *file)
+{
+ int lslash=0, i = 0;
+ for (i=0; string[i]!='\0'; i++) {
+ if (string[i]=='\\' || string[i]=='/')
+ lslash = i+1;
+ }
+ if (dir) {
+ if (lslash) {
+ BLI_strncpy( dir, string, lslash+1); /* +1 to include the slash and the last char */
+ } else {
+ dir[0] = '\0';
+ }
+ }
+
+ if (file) {
+ strcpy( file, string+lslash);
+ }
+}
+
-/* warning, can modify 'string' */
+/* Warning,
+ * - May modify 'string' variable
+ * - May create the directory if it dosnt exist
+ * if this is not needed use BLI_split_dirfile_basic(...)
+ */
void BLI_split_dirfile(char *string, char *dir, char *file)
{
int a;