Skip to content

Commit

Permalink
Added U7opendir so ExultStudio will check for upper-case paths
Browse files Browse the repository at this point in the history
  • Loading branch information
drcode1 committed Feb 26, 2017
1 parent 85c0671 commit b93a828
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
15 changes: 15 additions & 0 deletions files/utils.cc
Expand Up @@ -399,6 +399,21 @@ std::FILE *U7open(
return 0;
}

DIR *U7opendir(
const char *fname // May be converted to upper-case.
) {
DIR *dir;
string name = get_system_path(fname);
int uppercasecount = 0;

do {
dir = opendir(name.c_str()); // Try to open
if (dir)
return dir; // found it!
} while (base_to_uppercase(name, ++uppercasecount));
return 0;
}

/*
* Remove a file taking care of paths etc.
*
Expand Down
4 changes: 4 additions & 0 deletions files/utils.h
Expand Up @@ -28,6 +28,7 @@
#include <cstdio>
#include <stdio.h>
#include <iosfwd>
#include <dirent.h>

#include "common_types.h"
#include "rect.h"
Expand Down Expand Up @@ -562,6 +563,9 @@ bool U7open_static(
const char *fname, // May be converted to upper-case.
bool is_text // Should file be opened in text mode
);
DIR *U7opendir(
const char *fname // May be converted to upper-case.
);
void U7remove(
const char *fname
);
Expand Down
6 changes: 2 additions & 4 deletions mapedit/studio.cc
Expand Up @@ -1356,14 +1356,12 @@ void add_to_tree(GtkTreeStore *model, const char *folderName,
}

string spath("<STATIC>"), ppath("<PATCH>");
spath = get_system_path(spath);
ppath = get_system_path(ppath);
const char *ext = strstr(pattern, "*");
if (!ext)
ext = pattern;
else
ext++;
DIR *dir = opendir(ppath.c_str());// Get names from 'patch' first.
DIR *dir = U7opendir(ppath.c_str());// Get names from 'patch' first.
if (dir) {
while ((entry = readdir(dir))) {
char *fname = entry->d_name;
Expand All @@ -1380,7 +1378,7 @@ void add_to_tree(GtkTreeStore *model, const char *folderName,
}
closedir(dir);
}
dir = opendir(spath.c_str()); // Now go through 'static'.
dir = U7opendir(spath.c_str()); // Now go through 'static'.
if (dir) {
while ((entry = readdir(dir))) {
char *fname = entry->d_name;
Expand Down

0 comments on commit b93a828

Please sign in to comment.