fix [#26803] Libs paths are case sensitive in windows
use case insensitive path comparison on windows: BLI_path_cmp
This commit is contained in:
parent
5c7bed92d4
commit
a7507e945d
@ -60,7 +60,7 @@ static DirBLF *blf_dir_find(const char *path)
|
||||
|
||||
p= global_font_dir.first;
|
||||
while (p) {
|
||||
if (!strcmp(p->path, path))
|
||||
if (BLI_path_cmp(p->path, path) == 0)
|
||||
return(p);
|
||||
p= p->next;
|
||||
}
|
||||
|
@ -158,9 +158,16 @@ int BLI_path_abs(char *path, const char *basepath);
|
||||
int BLI_path_frame(char *path, int frame, int digits);
|
||||
int BLI_path_frame_range(char *path, int sta, int end, int digits);
|
||||
int BLI_path_cwd(char *path);
|
||||
|
||||
void BLI_path_rel(char *file, const char *relfile);
|
||||
|
||||
#ifdef WIN32
|
||||
# define BLI_path_cmp BLI_strcasecmp
|
||||
# define BLI_path_ncmp BLI_strncasecmp
|
||||
#else
|
||||
# define BLI_path_cmp strcmp
|
||||
# define BLI_path_ncmp strncmp
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Change every @a from in @a string into @a to. The
|
||||
* result will be in @a string
|
||||
|
@ -1481,7 +1481,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
|
||||
if (!strncmp(path, blend_dir, len)) {
|
||||
|
||||
/* if image is _in_ current .blend file directory */
|
||||
if (!strcmp(dir, blend_dir)) {
|
||||
if (BLI_path_cmp(dir, blend_dir) == 0) {
|
||||
BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base);
|
||||
}
|
||||
/* "below" */
|
||||
@ -1508,7 +1508,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
|
||||
}
|
||||
|
||||
/* return 2 if src=dest */
|
||||
if (!strcmp(path, dest_path)) {
|
||||
if (BLI_path_cmp(path, dest_path) == 0) {
|
||||
// if (G.f & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path);
|
||||
return 2;
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, c
|
||||
for (m= mainlist->first; m; m= m->next) {
|
||||
char *libname= (m->curlib)?m->curlib->filepath:m->name;
|
||||
|
||||
if (BLI_streq(name1, libname)) {
|
||||
if (BLI_path_cmp(name1, libname) == 0) {
|
||||
if(G.f & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
|
||||
return m;
|
||||
}
|
||||
@ -5449,7 +5449,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
for(newmain= fd->mainlist.first; newmain; newmain= newmain->next) {
|
||||
if(newmain->curlib) {
|
||||
if(strcmp(newmain->curlib->filepath, lib->filepath)==0) {
|
||||
if(BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
|
||||
printf("Fixed error in file; multiple instances of lib:\n %s\n", lib->filepath);
|
||||
BKE_reportf(fd->reports, RPT_WARNING, "Library '%s', '%s' had multiple instances, save and reload!", lib->name, lib->filepath);
|
||||
|
||||
|
@ -2547,7 +2547,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
|
||||
}
|
||||
|
||||
BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
|
||||
write_user_block= BLI_streq(dir, userfilename);
|
||||
write_user_block= (BLI_path_cmp(dir, userfilename) == 0);
|
||||
|
||||
if(write_flags & G_FILE_RELATIVE_REMAP)
|
||||
makeFilesRelative(mainvar, dir, NULL); /* note, making relative to something OTHER then G.main->name */
|
||||
|
@ -73,8 +73,9 @@
|
||||
/* make layer active one after being clicked on */
|
||||
static void gp_ui_activelayer_cb (bContext *C, void *gpd, void *gpl)
|
||||
{
|
||||
/* make sure the layer we want to remove is the active one */
|
||||
gpencil_layer_setactive(gpd, gpl);
|
||||
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
|
||||
}
|
||||
|
||||
@ -88,13 +89,7 @@ static void gp_ui_dellayer_cb (bContext *C, void *gpd, void *gpl)
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
|
||||
}
|
||||
|
||||
static void gp_ui_actlayer_cb (bContext *C, void *gpd, void *gpl)
|
||||
{
|
||||
/* make sure the layer we want to remove is the active one */
|
||||
gpencil_layer_setactive(gpd, gpl);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
|
||||
}
|
||||
|
||||
/* ------- Drawing Code ------- */
|
||||
|
||||
|
@ -686,7 +686,7 @@ int UI_iconfile_get_index(const char *filename)
|
||||
ListBase *list=&(iconfilelist);
|
||||
|
||||
for(ifile=list->first; ifile; ifile=ifile->next) {
|
||||
if ( BLI_streq(filename, ifile->filename)) {
|
||||
if (BLI_path_cmp(filename, ifile->filename) == 0) {
|
||||
return ifile->index;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
|
||||
|
||||
/* set this list item as active if we have a match */
|
||||
if(sfile->params) {
|
||||
if(strcmp(sfile->params->dir, entry) == 0) {
|
||||
if(BLI_path_cmp(sfile->params->dir, entry) == 0) {
|
||||
*nr= i;
|
||||
}
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ int folderlist_clear_next(struct SpaceFile *sfile)
|
||||
|
||||
// if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next
|
||||
folder = sfile->folders_prev->last;
|
||||
if ((!folder) ||(!strcmp(folder->foldername, sfile->params->dir)))
|
||||
if ((!folder) ||(BLI_path_cmp(folder->foldername, sfile->params->dir) == 0))
|
||||
return 0;
|
||||
|
||||
// eventually clear flist->folders_next
|
||||
@ -697,7 +697,7 @@ int filelist_find(struct FileList* filelist, char *file)
|
||||
|
||||
|
||||
for (i = 0; i < filelist->numfiles; ++i) {
|
||||
if ( strcmp(filelist->filelist[i].relname, file) == 0) {
|
||||
if ( strcmp(filelist->filelist[i].relname, file) == 0) { /* not dealing with user input so dont need BLI_path_cmp */
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
@ -880,7 +880,7 @@ static void filelist_read_library(struct FileList* filelist)
|
||||
strcat(name, file->relname);
|
||||
|
||||
/* prevent current file being used as acceptable dir */
|
||||
if (BLI_streq(G.main->name, name)==0) {
|
||||
if (BLI_path_cmp(G.main->name, name) != 0) {
|
||||
file->type &= ~S_IFMT;
|
||||
file->type |= S_IFDIR;
|
||||
}
|
||||
|
@ -173,9 +173,11 @@ void fsmenu_insert_entry(struct FSMenu* fsmenu, FSMenuCategory category, const c
|
||||
|
||||
for (; fsme; prev= fsme, fsme= fsme->next) {
|
||||
if (fsme->path) {
|
||||
if (BLI_streq(path, fsme->path)) {
|
||||
const int cmp_ret= BLI_path_cmp(path, fsme->path);
|
||||
if (cmp_ret == 0) {
|
||||
return;
|
||||
} else if (sorted && strcmp(path, fsme->path)<0) {
|
||||
}
|
||||
else if (sorted && cmp_ret < 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -281,7 +281,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
|
||||
BLI_snprintf(tpath, FILE_MAX, "%s%s", tdir, thumb);
|
||||
thumb[8] = '\0'; /* shorten for tempname, not needed anymore */
|
||||
BLI_snprintf(temp, FILE_MAX, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb);
|
||||
if (strncmp(path, tdir, strlen(tdir)) == 0) {
|
||||
if (BLI_path_ncmp(path, tdir, sizeof(tdir)) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (size == THB_FAIL) {
|
||||
@ -387,7 +387,7 @@ void IMB_thumb_delete(const char* path, ThumbSize size)
|
||||
return;
|
||||
}
|
||||
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
|
||||
if (strncmp(path, thumb, strlen(thumb)) == 0) {
|
||||
if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
|
||||
return;
|
||||
}
|
||||
if (BLI_exists(thumb)) {
|
||||
@ -419,7 +419,7 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source)
|
||||
}
|
||||
|
||||
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
|
||||
if (strncmp(path, thumb, strlen(thumb)) == 0) {
|
||||
if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
|
||||
img = IMB_loadiffname(path, IB_rect);
|
||||
} else {
|
||||
img = IMB_loadiffname(thumb, IB_rect | IB_metadata);
|
||||
|
@ -194,7 +194,7 @@ int DNA_elem_array_size(const char *astr, int len)
|
||||
void DNA_sdna_free(SDNA *sdna)
|
||||
{
|
||||
MEM_freeN(sdna->data);
|
||||
MEM_freeN(sdna->names);
|
||||
MEM_freeN((void *)sdna->names);
|
||||
MEM_freeN(sdna->types);
|
||||
MEM_freeN(sdna->structs);
|
||||
|
||||
|
@ -115,7 +115,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
|
||||
}
|
||||
else {
|
||||
lib= BLI_bpathIterator_getLib(bpi);
|
||||
if (lib && (strcmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
|
||||
if (lib && (BLI_path_cmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
|
||||
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
|
||||
}
|
||||
else {
|
||||
|
@ -510,7 +510,7 @@ static void write_history(void)
|
||||
|
||||
recent = G.recent_files.first;
|
||||
/* refresh recent-files.txt of recent opened files, when current file was changed */
|
||||
if(!(recent) || (strcmp(recent->filepath, G.main->name)!=0)) {
|
||||
if(!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) {
|
||||
fp= fopen(name, "w");
|
||||
if (fp) {
|
||||
/* add current file to the beginning of list */
|
||||
@ -524,7 +524,7 @@ static void write_history(void)
|
||||
/* write rest of recent opened files to recent-files.txt */
|
||||
while((i<U.recent_files) && (recent)){
|
||||
/* this prevents to have duplicities in list */
|
||||
if (strcmp(recent->filepath, G.main->name)!=0) {
|
||||
if (BLI_path_cmp(recent->filepath, G.main->name)!=0) {
|
||||
fprintf(fp, "%s\n", recent->filepath);
|
||||
recent = recent->next;
|
||||
}
|
||||
@ -656,7 +656,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
|
||||
|
||||
/* send the OnSave event */
|
||||
for (li= G.main->library.first; li; li= li->id.next) {
|
||||
if (strcmp(li->filepath, di) == 0) {
|
||||
if (BLI_path_cmp(li->filepath, di) == 0) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", di);
|
||||
return -1;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname)
|
||||
void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
|
||||
{
|
||||
if (keyconf) {
|
||||
if (BLI_streq(U.keyconfigstr, keyconf->idname)) {
|
||||
if (strncmp(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr)) == 0) {
|
||||
BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr));
|
||||
}
|
||||
|
||||
|
@ -1133,8 +1133,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
|
||||
sprintf(revision_str, "r%s", build_rev);
|
||||
|
||||
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
|
||||
ver_width = BLF_width(style->widgetlabel.uifont_id, version_str)+5;
|
||||
rev_width = BLF_width(style->widgetlabel.uifont_id, revision_str)+5;
|
||||
ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5;
|
||||
rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_str) + 5;
|
||||
#endif //NAN_BUILDINFO
|
||||
|
||||
block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
|
||||
@ -1522,7 +1522,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else if(BLI_streq(bmain->name, libname)) {
|
||||
else if(BLI_path_cmp(bmain->name, libname) == 0) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
@ -926,7 +926,7 @@ vector<Main*> &KX_BlenderSceneConverter::GetMainDynamic()
|
||||
Main* KX_BlenderSceneConverter::GetMainDynamicPath(const char *path)
|
||||
{
|
||||
for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++)
|
||||
if(strcmp((*it)->name, path)==0)
|
||||
if(BLI_path_cmp((*it)->name, path) == 0)
|
||||
return *it;
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user