/** * 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'; }
bool file_draw_check_exists(SpaceFile *sfile) { if (sfile->op) { /* fails on reload */ if (RNA_struct_find_property(sfile->op->ptr, "check_existing")) { if (RNA_boolean_get(sfile->op->ptr, "check_existing")) { char filepath[FILE_MAX]; BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file); if (BLI_is_file(filepath)) { return true; } } } } return false; }