summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-10-18 13:29:03 +0200
committerGitHub <noreply@github.com>2019-10-18 13:29:03 +0200
commitef60d6c53db89a6a932618895acf4ee194b3f2e3 (patch)
tree5683ad48dd74af701b463a5aeaad7b7f58f95705 /src/common
parent1e6580e56850adb241261c33bffca60f934294fb (diff)
parentae22cb6f20091e290cf6c30c049400535d6f1aca (diff)
downloadhercules-ef60d6c53db89a6a932618895acf4ee194b3f2e3.tar.gz
hercules-ef60d6c53db89a6a932618895acf4ee194b3f2e3.tar.bz2
hercules-ef60d6c53db89a6a932618895acf4ee194b3f2e3.tar.xz
hercules-ef60d6c53db89a6a932618895acf4ee194b3f2e3.zip
Merge pull request #2492 from dastgirp/huld/split
Split HULD translations to per NPC file instead of one large file
Diffstat (limited to 'src/common')
-rw-r--r--src/common/utils.c15
-rw-r--r--src/common/utils.h2
2 files changed, 8 insertions, 9 deletions
diff --git a/src/common/utils.c b/src/common/utils.c
index d4c838b56..238ebe65d 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -128,7 +128,7 @@ static char *checkpath(char *path, const char *srcpath)
return path;
}
-void findfile(const char *p, const char *pat, void (func)(const char *))
+void findfile(const char *p, const char *pat, void (func)(const char *, void *context), void *context)
{
WIN32_FIND_DATAA FindFileData;
HANDLE hFind;
@@ -155,12 +155,11 @@ void findfile(const char *p, const char *pat, void (func)(const char *))
sprintf(tmppath,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
if (strstr(FindFileData.cFileName, pattern)) {
- func( tmppath );
+ func(tmppath, context);
}
- if( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- {
- findfile(tmppath, pat, func);
+ if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ findfile(tmppath, pat, func, context);
}
}while (FindNextFileA(hFind, &FindFileData) != 0);
FindClose(hFind);
@@ -190,7 +189,7 @@ static char *checkpath(char *path, const char *srcpath)
return path;
}
-void findfile(const char *p, const char *pat, void (func)(const char *))
+void findfile(const char *p, const char *pat, void (func)(const char *, void *context), void *context)
{
DIR* dir; ///< pointer to the scanned directory.
struct dirent* entry; ///< pointer to one directory entry.
@@ -220,7 +219,7 @@ void findfile(const char *p, const char *pat, void (func)(const char *))
// check if the pattern matches.
if (strstr(entry->d_name, pattern)) {
- func( tmppath );
+ func(tmppath, context);
}
// check if it is a directory.
if (stat(tmppath, &dir_stat) == -1) {
@@ -230,7 +229,7 @@ void findfile(const char *p, const char *pat, void (func)(const char *))
// is this a directory?
if (S_ISDIR(dir_stat.st_mode)) {
// decent recursively
- findfile(tmppath, pat, func);
+ findfile(tmppath, pat, func, context);
}
}//end while
diff --git a/src/common/utils.h b/src/common/utils.h
index f564dcf29..81234c843 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -39,7 +39,7 @@
void WriteDump(FILE* fp, const void* buffer, size_t length);
void ShowDump(const void* buffer, size_t length);
-void findfile(const char *p, const char *pat, void (func)(const char*));
+void findfile(const char *p, const char *pat, void (func)(const char *, void *), void *context);
bool exists(const char* filename);
/// calculates the value of A / B, in percent (rounded down)