summaryrefslogtreecommitdiff
path: root/rts/PathUtils.h
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-10-23 14:03:48 -0400
committerBen Gamari <ben@smart-cactus.org>2016-10-23 14:05:10 -0400
commitf084e6845515fbfb774a09ae5d2af1eea8fdc3f0 (patch)
tree780b9a2e21d79055b0abe05f6c93fefee8e1c36b /rts/PathUtils.h
parenta6bcf8783ff758a82d003ea8f669d7216695fa59 (diff)
downloadhaskell-f084e6845515fbfb774a09ae5d2af1eea8fdc3f0.tar.gz
rts: Move path utilities to separate source file
Test Plan: Validate Reviewers: simonmar, austin, erikd Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2614
Diffstat (limited to 'rts/PathUtils.h')
-rw-r--r--rts/PathUtils.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/rts/PathUtils.h b/rts/PathUtils.h
new file mode 100644
index 0000000000..4821938d7d
--- /dev/null
+++ b/rts/PathUtils.h
@@ -0,0 +1,43 @@
+/* ---------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 2001-2016
+ *
+ * Platform-independent path manipulation utilities
+ *
+ * --------------------------------------------------------------------------*/
+
+#ifndef PATH_UTILS_H
+#define PATH_UTILS_H
+
+#include "BeginPrivate.h"
+
+// Use wchar_t for pathnames on Windows (#5697)
+#if defined(mingw32_HOST_OS)
+#define pathcmp wcscmp
+#define pathlen wcslen
+#define pathopen _wfopen
+#define pathstat _wstat
+#define struct_stat struct _stat
+#define open wopen
+#define WSTR(s) L##s
+#define pathprintf swprintf
+#define pathsize sizeof(wchar_t)
+#else
+#define pathcmp strcmp
+#define pathlen strlen
+#define pathopen fopen
+#define pathstat stat
+#define struct_stat struct stat
+#define WSTR(s) s
+#define pathprintf snprintf
+#define pathsize sizeof(char)
+#endif
+
+pathchar* pathdup(pathchar *path);
+pathchar* pathdir(pathchar *path);
+pathchar* mkPath(char* path);
+HsBool endsWithPath(pathchar* base, pathchar* str);
+
+#include "EndPrivate.h"
+
+#endif /* PATH_UTILS_H */