]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/tools/toolutil/toolutil.cpp
ICU-551.30.tar.gz
[apple/icu.git] / icuSources / tools / toolutil / toolutil.cpp
index 7c02efc37b107c5658d7fb656a4c8bac0a9a5544..6d90efc297c277e398c57d65d5df8dfff4a78af3 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1999-2011, International Business Machines
+*   Copyright (C) 1999-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
 *   This file contains utility functions for ICU tools like genccode.
 */
 
+#include "unicode/platform.h"
+#if U_PLATFORM == U_PF_MINGW
+// *cough* - for struct stat
+#ifdef __STRICT_ANSI__
+#undef __STRICT_ANSI__
+#endif
+#endif
+
 #include <stdio.h>
 #include <sys/stat.h>
 #include "unicode/utypes.h"
@@ -33,6 +41,9 @@
 #   define NOSERVICE
 #   define NOIME
 #   define NOMCX
+#   if U_PLATFORM == U_PF_MINGW
+#     define __NO_MINGW_LFS /* gets around missing 'off64_t' */
+#   endif
 #   include <windows.h>
 #   include <direct.h>
 #else
@@ -151,7 +162,10 @@ findBasename(const char *filename) {
     const char *basename=uprv_strrchr(filename, U_FILE_SEP_CHAR);
 
 #if U_FILE_ALT_SEP_CHAR!=U_FILE_SEP_CHAR
-    if(basename==NULL) {
+#if !(U_PLATFORM == U_PF_CYGWIN && U_PLATFORM_USES_ONLY_WIN32_API)
+    if(basename==NULL)
+#endif
+    {
         /* Use lenient matching on Windows, which can accept either \ or /
            This is useful for environments like Win32+CygWin which have both.
         */
@@ -191,6 +205,18 @@ uprv_mkdir(const char *pathname, UErrorCode *status) {
     }
 }
 
+#if !UCONFIG_NO_FILE_IO
+U_CAPI UBool U_EXPORT2
+uprv_fileExists(const char *file) {
+  struct stat stat_buf;
+  if (stat(file, &stat_buf) == 0) {
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+}
+#endif
+
 /*U_CAPI UDate U_EXPORT2
 uprv_getModificationDate(const char *pathname, UErrorCode *status)
 {