Speed-up the validation of the cache by skipping media directories...
...(images and sounds) because we don't cache those. This seems to really help this process. (~80% of files are images and the check is proportional to the number of files) The only problem is if weird UMC put some cfg in /images. But the unchecked cache will just annoy the author when he will editing only this cfg. This will also helps artists by avoiding useless cache rebuilding. PS: also did a tiny safe change in Mac-specific code for unicode filename, and a cleaner file extension check is much less effective than the directory skip.
This commit is contained in:
parent
4adbb190b2
commit
a623423198
3 changed files with 17 additions and 9 deletions
|
@ -312,6 +312,7 @@ void get_files_in_dir(const std::string& directory,
|
|||
std::vector<std::string>* files,
|
||||
std::vector<std::string>* dirs,
|
||||
FILE_NAME_MODE mode,
|
||||
FILE_FILTER filter,
|
||||
FILE_REORDER_OPTION reorder)
|
||||
{
|
||||
// If we have a path to find directories in,
|
||||
|
@ -321,7 +322,7 @@ void get_files_in_dir(const std::string& directory,
|
|||
if(!directory.empty() && directory[0] != '/' && !game_config::path.empty()){
|
||||
const std::string& dir = game_config::path + "/" + directory;
|
||||
if(is_directory(dir)) {
|
||||
get_files_in_dir(dir,files,dirs,mode,reorder);
|
||||
get_files_in_dir(dir,files,dirs,mode,filter,reorder);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +367,7 @@ void get_files_in_dir(const std::string& directory,
|
|||
#ifdef __APPLE__
|
||||
// HFS Mac OS X decomposes filenames using combining unicode characters.
|
||||
// Try to get the precomposed form.
|
||||
char basename[MAXNAMLEN+1];
|
||||
char macname[MAXNAMLEN+1];
|
||||
CFStringRef cstr = CFStringCreateWithCString(NULL,
|
||||
entry->d_name,
|
||||
kCFStringEncodingUTF8);
|
||||
|
@ -374,13 +375,14 @@ void get_files_in_dir(const std::string& directory,
|
|||
0, cstr);
|
||||
CFStringNormalize(mut_str, kCFStringNormalizationFormC);
|
||||
CFStringGetCString(mut_str,
|
||||
basename,sizeof(basename)-1,
|
||||
macname,sizeof(macname)-1,
|
||||
kCFStringEncodingUTF8);
|
||||
CFRelease(cstr);
|
||||
CFRelease(mut_str);
|
||||
const std::string basename = macname;
|
||||
#else
|
||||
// generic Unix
|
||||
char *basename = entry->d_name;
|
||||
const std::string basename = entry->d_name;
|
||||
#endif /* !APPLE */
|
||||
|
||||
std::string fullname;
|
||||
|
@ -391,7 +393,7 @@ void get_files_in_dir(const std::string& directory,
|
|||
)
|
||||
fullname = directory + basename;
|
||||
else
|
||||
fullname = (directory + "/") + basename;
|
||||
fullname = directory + "/" + basename;
|
||||
|
||||
if (::stat(fullname.c_str(), &st) != -1) {
|
||||
if (S_ISREG(st.st_mode)) {
|
||||
|
@ -402,6 +404,10 @@ void get_files_in_dir(const std::string& directory,
|
|||
files->push_back(basename);
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
if (filter == SKIP_MEDIA_DIR
|
||||
&& (basename == "images"|| basename == "sounds"))
|
||||
continue;
|
||||
|
||||
if (reorder == DO_REORDER &&
|
||||
::stat((fullname+"/"+MAINCFG).c_str(), &st)!=-1 &&
|
||||
S_ISREG(st.st_mode)) {
|
||||
|
@ -411,8 +417,8 @@ void get_files_in_dir(const std::string& directory,
|
|||
files->push_back(fullname + "/" + MAINCFG);
|
||||
LOG_FS << fullname << "/" << MAINCFG << '\n';
|
||||
} else {
|
||||
files->push_back(std::string(basename) + "/" + MAINCFG);
|
||||
LOG_FS << std::string(basename) << "/" << MAINCFG << '\n';
|
||||
files->push_back(basename + "/" + MAINCFG);
|
||||
LOG_FS << basename << "/" << MAINCFG << '\n';
|
||||
}
|
||||
} else {
|
||||
// Show what I consider strange
|
||||
|
@ -867,7 +873,7 @@ bool operator!=(const file_tree_checksum& lhs, const file_tree_checksum& rhs)
|
|||
static void get_file_tree_checksum_internal(const std::string& path, file_tree_checksum& res)
|
||||
{
|
||||
std::vector<std::string> files, dirs;
|
||||
get_files_in_dir(path,&files,&dirs,ENTIRE_FILE_PATH);
|
||||
get_files_in_dir(path,&files,&dirs, ENTIRE_FILE_PATH, SKIP_MEDIA_DIR);
|
||||
increment_filesystem_progress();
|
||||
for(std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) {
|
||||
++res.nfiles;
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
};
|
||||
|
||||
enum FILE_NAME_MODE { ENTIRE_FILE_PATH, FILE_NAME_ONLY };
|
||||
enum FILE_FILTER { NO_FILTER, SKIP_MEDIA_DIR};
|
||||
enum FILE_REORDER_OPTION { DONT_REORDER, DO_REORDER };
|
||||
|
||||
//! Populates 'files' with all the files and
|
||||
|
@ -47,6 +48,7 @@ void get_files_in_dir(const std::string& dir,
|
|||
std::vector<std::string>* files,
|
||||
std::vector<std::string>* dirs=NULL,
|
||||
FILE_NAME_MODE mode=FILE_NAME_ONLY,
|
||||
FILE_FILTER = NO_FILTER,
|
||||
FILE_REORDER_OPTION reorder=DONT_REORDER);
|
||||
|
||||
std::string get_dir(const std::string &dir);
|
||||
|
|
|
@ -270,7 +270,7 @@ preprocessor_file::preprocessor_file(preprocessor_streambuf &t,
|
|||
end_()
|
||||
{
|
||||
if (is_directory(name))
|
||||
get_files_in_dir(name, &files_, NULL, ENTIRE_FILE_PATH, DO_REORDER);
|
||||
get_files_in_dir(name, &files_, NULL, ENTIRE_FILE_PATH, SKIP_MEDIA_DIR, DO_REORDER);
|
||||
else
|
||||
new preprocessor_data(t, istream_file(name), "", name, 1, directory_name(name), t.textdomain_);
|
||||
pos_ = files_.begin();
|
||||
|
|
Loading…
Add table
Reference in a new issue