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>2009-07-19 21:45:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-19 21:45:14 +0400
commit979bec79c373b5bfae0bfe6e74e6e92bf3214ff2 (patch)
tree291054f0baf5e95ff118137863cccf0867b4b53c /source/blender/blenlib/intern/util.c
parentd410135408fcce7856cc044ba717297c89302a34 (diff)
- Support for importing python packages. (directories of python scripts containing an __init__.py)
- BLI_add_slash returns the new string length. - BLI_where_am_i() would often have /./ in the path (not incorrect but annoying, got into python exceptions) - release/ui/space_image.py, py error referencing invalid keyword args.
Diffstat (limited to 'source/blender/blenlib/intern/util.c')
-rw-r--r--source/blender/blenlib/intern/util.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index 78a4599b3b3..8eeca6900a1 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -499,9 +499,8 @@ int BLI_has_parent(char *path)
int len;
int slashes = 0;
BLI_clean(path);
- BLI_add_slash(path);
+ len = BLI_add_slash(path) - 1;
- len = strlen(path)-1;
while (len>=0) {
if ((path[len] == '\\') || (path[len] == '/'))
slashes++;
@@ -1276,22 +1275,12 @@ void BLI_split_dirfile(char *string, char *dir, char *file)
/* simple appending of filename to dir, does not check for valid path! */
void BLI_join_dirfile(char *string, const char *dir, const char *file)
{
- int sl_dir = strlen(dir);
- BLI_strncpy(string, dir, FILE_MAX);
- if (sl_dir > FILE_MAX-1) sl_dir = FILE_MAX-1;
+ int sl_dir;
- /* only add seperator if needed */
-#ifdef WIN32
- if (string[sl_dir-1] != '\\') {
- string[sl_dir] = '\\';
- sl_dir++;
- }
-#else
- if (string[sl_dir-1] != '/') {
- string[sl_dir] = '/';
- sl_dir++;
- }
-#endif
+ if(string != dir) /* compare pointers */
+ BLI_strncpy(string, dir, FILE_MAX);
+
+ sl_dir= BLI_add_slash(string);
if (sl_dir <FILE_MAX) {
BLI_strncpy(string + sl_dir, file, FILE_MAX-sl_dir);
@@ -1343,13 +1332,13 @@ void BLI_where_am_i(char *fullname, const char *name)
{
char filename[FILE_MAXDIR+FILE_MAXFILE];
char *path = NULL, *temp;
- int len;
+
#ifdef _WIN32
char *seperator = ";";
- char *slash = "\\";
+ char slash = '\\';
#else
char *seperator = ":";
- char *slash = "/";
+ char slash = '/';
#endif
@@ -1369,11 +1358,13 @@ void BLI_where_am_i(char *fullname, const char *name)
if (name[0] == '.') {
// relative path, prepend cwd
BLI_getwdN(fullname);
- len = strlen(fullname);
- if (len && fullname[len -1] != slash[0]) {
- strcat(fullname, slash);
- }
- strcat(fullname, name);
+
+ // not needed but avoids annoying /./ in name
+ if(name && name[0]=='.' && name[1]==slash)
+ BLI_join_dirfile(fullname, fullname, name+2);
+ else
+ BLI_join_dirfile(fullname, fullname, name);
+
add_win32_extension(fullname);
} else if (BLI_last_slash(name)) {
// full path
@@ -1392,11 +1383,7 @@ void BLI_where_am_i(char *fullname, const char *name)
} else {
strncpy(filename, path, sizeof(filename));
}
- len = strlen(filename);
- if (len && filename[len - 1] != slash[0]) {
- strcat(filename, slash);
- }
- strcat(filename, name);
+ BLI_join_dirfile(fullname, fullname, name);
if (add_win32_extension(filename)) {
strcpy(fullname, filename);
break;