summaryrefslogtreecommitdiff
path: root/rts/PathUtils.h
blob: 8a42e34b54a2ea45a0b50c10380d6139585eb029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ---------------------------------------------------------------------------
 *
 * (c) The GHC Team, 2001-2016
 *
 * Platform-independent path manipulation utilities
 *
 * --------------------------------------------------------------------------*/

#pragma once

#include "BeginPrivate.h"

// Use wchar_t for pathnames on Windows (#5697)
#if defined(mingw32_HOST_OS)
#include "fs_rts.h"

#define pathcmp wcscmp
#define pathlen wcslen
// N.B. Use the Win32-based file routines from utils/fs.
#define pathopen FS(fwopen)
#define pathstat FS(_wstat)
#define struct_stat struct _stat
#define open wopen
#define WSTR(s) L##s
#define pathprintf swprintf
#define pathcopy wcscpy
#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)
#define pathcopy strcpy
#endif

pathchar* pathdup(pathchar *path);
pathchar* pathdir(pathchar *path);
pathchar* mkPath(char* path);
HsBool endsWithPath(pathchar* base, pathchar* str);

#include "EndPrivate.h"