From 4727659db07cd1c472f5d5aec1aea648bd60cf8a Mon Sep 17 00:00:00 2001 From: s1lent Date: Sun, 29 Jan 2017 22:07:35 +0700 Subject: [PATCH] Ignore VS2015 files. Improve parsing resources.ini (Added chec on BOM signatures) --- .gitignore | 3 +++ msvc/rechecker.vcxproj | 6 +++--- src/resource.cpp | 28 ++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index f563d9d..aee68f6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,10 @@ **/msvc/*.opensdf **/msvc/*.user **/msvc/*.suo +**/msvc/*.db +**/msvc/*.opendb **/msvc/*.aps +**/msvc/.vs **/msvc/ipch **/PublishPath*.txt **/Server*.bat diff --git a/msvc/rechecker.vcxproj b/msvc/rechecker.vcxproj index 8e64b5b..a52f06f 100644 --- a/msvc/rechecker.vcxproj +++ b/msvc/rechecker.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -213,13 +213,13 @@ DynamicLibrary true - v120_xp + v140_xp MultiByte DynamicLibrary false - v120_xp + v140_xp true MultiByte diff --git a/src/resource.cpp b/src/resource.cpp index 147ddf3..5c482d8 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -192,13 +192,25 @@ void CResourceFile::Log(flag_type_log type, const char *fmt, ...) fclose(fp); } +#ifdef CreateDirectory +#undef CreateDirectory +#endif + void CreateDirectory(const char *path) { - _mkdir(path -#ifndef _WIN32 - ,0755 -#endif // _WIN32 - ); +#ifdef _WIN32 + DWORD attr = ::GetFileAttributesA(path); + if (attr == INVALID_FILE_ATTRIBUTES || (~attr & FILE_ATTRIBUTE_DIRECTORY)) + { + _mkdir(path); + } +#else + struct stat s; + if (stat(path, &s) != 0 || !S_ISDIR(s.st_mode)) + { + _mkdir(path, 0755); + } +#endif } void CResourceFile::Init() @@ -319,7 +331,11 @@ void CResourceFile::LoadResources() while (!feof(fp) && fgets(line, sizeof(line), fp)) { - pos = line; + // skip bytes BOM signature + if ((byte)line[0] == 0xEFu && (byte)line[1] == 0xBBu && (byte)line[2] == 0xBFu) + pos = &line[3]; + else + pos = line; cline++;