Skip to content

Commit 863689b

Browse files
committed
Fix compilation error on Windows
1 parent 33ac662 commit 863689b

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

src/Global.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
*/
1515

16+
#include <algorithm>
1617
#include <stdexcept>
1718
#include "Global.hpp"
1819

@@ -122,7 +123,7 @@ Global::Global()
122123
"COM7", "COM8", "COM9", "COM¹", "COM²", "COM³", "CON", "LPT0",
123124
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8",
124125
"LPT9", "NUL", "PRN"
125-
};
126+
};
126127

127128
set<string> reserved_set(reserved, reserved + 27);
128129
WIN_RESERVED = reserved_set;
@@ -385,13 +386,13 @@ Global::DataType Global::detectSimpleType(int count, const uint freqs0[]) {
385386
}
386387

387388
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
388-
bool Global::isReservedName(const string& fileName)
389+
bool Global::isReservedName(string fileName)
389390
{
390391
transform(fileName.begin(), fileName.end(), fileName.begin(), ::toupper);
391-
return WIN_RESERVED.find(fileName.begin) != WIN_RESERVED.end();
392+
return WIN_RESERVED.find(fileName) != WIN_RESERVED.end();
392393
}
393394
#else
394-
bool Global::isReservedName(const string&)
395+
bool Global::isReservedName(string)
395396
{
396397
return false;
397398
}

src/Global.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace kanzi {
5454

5555
static DataType detectSimpleType(int count, const uint histo[]);
5656

57-
static bool isReservedName(const std::string& fileName);
57+
static bool isReservedName(std::string fileName);
5858

5959
private:
6060
Global();

src/io/IOUtil.hpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace kanzi
7878
if (idx != std::string::npos) {
7979
_path = path.substr(0, idx + 1);
8080
_name = path.substr(idx + 1);
81-
}
81+
}
8282
else {
8383
_path = "";
8484
_name = path;
@@ -100,7 +100,7 @@ namespace kanzi
100100
};
101101

102102

103-
static inline void createFileList(std::string& target, std::vector<FileData>& files, const FileListConfig& cfg,
103+
static inline void createFileList(std::string& target, std::vector<FileData>& files, const FileListConfig& cfg,
104104
std::vector<std::string>& errors)
105105
{
106106
if (target.size() == 0)
@@ -152,7 +152,7 @@ namespace kanzi
152152
if (cfg._recursive) {
153153
if (target[target.size() - 1] != PATH_SEPARATOR)
154154
target += PATH_SEPARATOR;
155-
}
155+
}
156156
else {
157157
target.resize(target.size() - 1);
158158
}
@@ -191,7 +191,7 @@ namespace kanzi
191191
if ((idx != std::string::npos) && (idx < fullpath.length() - 1) && (fullpath[idx + 1] == '.'))
192192
continue;
193193
}
194-
194+
195195
if ((cfg._ignoreLinks == false) || (buffer.st_mode & S_IFMT) != S_IFLNK)
196196
#if __cplusplus >= 201103L
197197
files.emplace_back(fullpath, buffer.st_size, buffer.st_mtime);
@@ -203,10 +203,10 @@ namespace kanzi
203203
if (cfg._ignoreDotFiles == true) {
204204
size_t idx = fullpath.rfind(PATH_SEPARATOR);
205205

206-
if ((idx != std::string::npos) && (idx < fullpath.length() - 1) && (fullpath[idx + 1] == '.'))
206+
if ((idx != std::string::npos) && (idx < fullpath.length() - 1) && (fullpath[idx + 1] == '.'))
207207
continue;
208208
}
209-
209+
210210
createFileList(fullpath, files, cfg, errors);
211211
}
212212
}
@@ -247,10 +247,14 @@ namespace kanzi
247247
}
248248

249249

250-
static inline int mkdirAll(const std::string& path, mode_t mode = S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH | S_IXOTH) {
251-
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
250+
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
251+
static inline int mkdirAll(const std::string& path)
252+
{
252253
bool foundDrive = false;
253-
#endif
254+
#else
255+
static inline int mkdirAll(const std::string& path, mode_t mode = S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH | S_IXOTH)
256+
{
257+
#endif
254258

255259
int res = 0;
256260
errno = 0;
@@ -264,34 +268,34 @@ namespace kanzi
264268
if (curPath.length() == 0)
265269
continue;
266270

267-
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
271+
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
268272
//Skip if drive
269273
if ((foundDrive == false) && (curPath.length() == 2) && (curPath[1] == ':')) {
270274
foundDrive = true;
271275
continue;
272276
}
273-
#endif
277+
#endif
274278

275-
#if defined(_MSC_VER)
279+
#if defined(_MSC_VER)
276280
res = _mkdir(curPath.c_str());
277-
#elif defined(__MINGW32__)
281+
#elif defined(__MINGW32__)
278282
res = mkdir(curPath.c_str());
279-
#else
283+
#else
280284
res = mkdir(curPath.c_str(), mode);
281-
#endif
285+
#endif
282286
if ((res != 0) && (errno != EEXIST))
283287
return errno;
284288
}
285289
}
286290
errno = 0;
287291

288-
#if defined(_MSC_VER)
292+
#if defined(_MSC_VER)
289293
res = _mkdir(path.c_str());
290-
#elif defined(__MINGW32__)
294+
#elif defined(__MINGW32__)
291295
res = mkdir(path.c_str());
292-
#else
296+
#else
293297
res = mkdir(path.c_str(), mode);
294-
#endif
298+
#endif
295299

296300
return (res == 0) ? 0 : errno;
297301
}

0 commit comments

Comments
 (0)