static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_len) { if (!anim->index_dir[0]) { char fname[FILE_MAXFILE]; BLI_split_dirfile(anim->name, index_dir, fname, index_dir_len, sizeof(fname)); BLI_path_append(index_dir, index_dir_len, "BL_proxy"); BLI_path_append(index_dir, index_dir_len, fname); } else { BLI_strncpy(index_dir, anim->index_dir, index_dir_len); } }
/** * EditTranslation utility funcs and operator, * \note: this includes utility functions and button matching checks. * this only works in conjunction with a py operator! */ static void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen) { char tstr[32]; /* Should be more than enough! */ /* First, full lang code. */ BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng); BLI_join_dirfile(path, maxlen, root, uilng); BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) { return; } /* Now try without the second iso code part (_ES in es_ES). */ { const char *tc = NULL; size_t szt = 0; tstr[0] = '\0'; tc = strchr(uilng, '_'); if (tc) { szt = tc - uilng; if (szt < sizeof(tstr)) { /* Paranoid, should always be true! */ BLI_strncpy(tstr, uilng, szt + 1); /* +1 for '\0' char! */ } } if (tstr[0]) { /* Because of some codes like sr_SR@latin... */ tc = strchr(uilng, '@'); if (tc) { BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt); } BLI_join_dirfile(path, maxlen, root, tstr); strcat(tstr, ".po"); BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) { return; } } } /* Else no po file! */ path[0] = '\0'; }
/** * Checks if name is a fully qualified filename to an executable. * If not it searches $PATH for the file. On Windows it also * adds the correct extension (.com .exe etc) from * $PATHEXT if necessary. Also on Windows it translates * the name to its 8.3 version to prevent problems with * spaces and stuff. Final result is returned in fullname. * * \param fullname The full path and full name of the executable * (must be FILE_MAX minimum) * \param name The name of the executable (usually argv[0]) to be checked */ static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name) { char filename[FILE_MAX]; const char *path = NULL, *temp; #ifdef _WIN32 const char *separator = ";"; #else const char *separator = ":"; #endif #ifdef WITH_BINRELOC /* linux uses binreloc since argv[0] is not reliable, call br_init( NULL ) first */ path = br_find_exe(NULL); if (path) { BLI_strncpy(fullname, path, maxlen); free((void *)path); return; } #endif #ifdef _WIN32 wchar_t *fullname_16 = MEM_mallocN(maxlen * sizeof(wchar_t), "ProgramPath"); if (GetModuleFileNameW(0, fullname_16, maxlen)) { conv_utf_16_to_8(fullname_16, fullname, maxlen); if (!BLI_exists(fullname)) { printf("path can't be found: \"%.*s\"\n", (int)maxlen, fullname); MessageBox(NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK); } MEM_freeN(fullname_16); return; } MEM_freeN(fullname_16); #endif /* unix and non linux */ if (name && name[0]) { BLI_strncpy(fullname, name, maxlen); if (name[0] == '.') { char wdir[FILE_MAX] = ""; BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ // not needed but avoids annoying /./ in name if (name[1] == SEP) BLI_join_dirfile(fullname, maxlen, wdir, name + 2); else BLI_join_dirfile(fullname, maxlen, wdir, name); add_win32_extension(fullname); /* XXX, doesnt respect length */ } else if (BLI_last_slash(name)) { // full path BLI_strncpy(fullname, name, maxlen); add_win32_extension(fullname); } else { // search for binary in $PATH path = getenv("PATH"); if (path) { do { temp = strstr(path, separator); if (temp) { strncpy(filename, path, temp - path); filename[temp - path] = 0; path = temp + 1; } else { strncpy(filename, path, sizeof(filename)); } BLI_path_append(fullname, maxlen, name); if (add_win32_extension(filename)) { BLI_strncpy(fullname, filename, maxlen); break; } } while (temp); } } #if defined(DEBUG) if (!STREQ(name, fullname)) { printf("guessing '%s' == '%s'\n", name, fullname); } #endif } }