diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_winstuff.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_bfile.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 26 |
3 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index 757b3605203..77d41e2b96a 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -129,6 +129,7 @@ struct dirent *readdir(DIR *dp); int closedir (DIR *dp); void get_default_root(char *root); int check_file_chars(char *filename); +char *dirname(char *path); #ifdef WIN32 int BLI_getInstallationDir(char *str); diff --git a/source/blender/blenlib/intern/BLI_bfile.c b/source/blender/blenlib/intern/BLI_bfile.c index 093168bbb82..042cf4beffc 100644 --- a/source/blender/blenlib/intern/BLI_bfile.c +++ b/source/blender/blenlib/intern/BLI_bfile.c @@ -29,6 +29,7 @@ #ifndef WIN32 #include <unistd.h> #include <sys/param.h> +// #include <libgen.h> #else #include <io.h> #include "BLI_winstuff.h" @@ -36,7 +37,6 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#include <libgen.h> #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 2f96f7b6af1..16295fc2680 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -217,6 +217,32 @@ int check_file_chars(char *filename) return 1; } +/* Copied from http://sourceware.org/ml/newlib/2005/msg00248.html */ +/* Copyright 2005 Shaun Jackman + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ +#include <string.h> +char* dirname(char *path) +{ + char *p; + if( path == NULL || *path == '\0' ) + return "."; + p = path + strlen(path) - 1; + while( *p == '/' ) { + if( p == path ) + return path; + *p-- = '\0'; + } + while( p >= path && *p != '/' ) + p--; + return + p < path ? "." : + p == path ? "/" : + (*p = '\0', path); +} +/* End of copied part */ + #else /* intentionally empty for UNIX */ |