annotate dmd/root/root.c @ 1194:1853dcd9b944

Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 03 Apr 2009 17:02:52 +0200
parents
children e961851fb8be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1194
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
2 // Copyright (c) 1999-2009 by Digital Mars
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
3 // All Rights Reserved
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
4 // written by Walter Bright
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
5 // www.digitalmars.com
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
6 // License for redistribution is by either the Artistic License
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
7 // in artistic.txt, or the GNU General Public License in gnu.txt.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
8 // See the included readme.txt for details.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
9
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
10 #include <stdio.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
11 #include <stdlib.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
12 #include <stdarg.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
13 #include <string.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
14 #include <stdint.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
15 #include <assert.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
16
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
17 #if (defined (__SVR4) && defined (__sun))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
18 #include <alloca.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
19 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
20
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
21 #if _MSC_VER ||__MINGW32__
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
22 #include <malloc.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
23 #include <string>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
24 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
25
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
26 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
27 #include <windows.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
28 #include <direct.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
29 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
30
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
31 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
32 #include <sys/types.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
33 #include <sys/stat.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
34 #include <fcntl.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
35 #include <errno.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
36 #include <unistd.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
37 #include <utime.h>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
38 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
39
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
40 #include "port.h"
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
41 #include "root.h"
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
42 #include "dchar.h"
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
43 #include "rmem.h"
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
44 #include "mars.h"
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
45
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
46 #if 0 //__SC__ //def DEBUG
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
47 extern "C" void __cdecl _assert(void *e, void *f, unsigned line)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
48 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
49 printf("Assert('%s','%s',%d)\n",e,f,line);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
50 fflush(stdout);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
51 *(char *)0 = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
52 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
53 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
54
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
55
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
56 /*************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
57 * Convert wchar string to ascii string.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
58 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
59
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
60 char *wchar2ascii(wchar_t *us)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
61 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
62 return wchar2ascii(us, wcslen(us));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
63 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
64
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
65 char *wchar2ascii(wchar_t *us, unsigned len)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
66 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
67 unsigned i;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
68 char *p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
69
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
70 p = (char *)mem.malloc(len + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
71 for (i = 0; i <= len; i++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
72 p[i] = (char) us[i];
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
73 return p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
74 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
75
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
76 int wcharIsAscii(wchar_t *us)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
77 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
78 return wcharIsAscii(us, wcslen(us));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
79 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
80
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
81 int wcharIsAscii(wchar_t *us, unsigned len)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
82 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
83 unsigned i;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
84
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
85 for (i = 0; i <= len; i++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
86 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
87 if (us[i] & ~0xFF) // if high bits set
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
88 return 0; // it's not ascii
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
89 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
90 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
91 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
92
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
93
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
94 /***********************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
95 * Compare length-prefixed strings (bstr).
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
96 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
97
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
98 int bstrcmp(unsigned char *b1, unsigned char *b2)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
99 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
100 return (*b1 == *b2 && memcmp(b1 + 1, b2 + 1, *b2) == 0) ? 0 : 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
101 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
102
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
103 /***************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
104 * Convert bstr into a malloc'd string.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
105 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
106
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
107 char *bstr2str(unsigned char *b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
108 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
109 char *s;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
110 unsigned len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
111
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
112 len = *b;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
113 s = (char *) mem.malloc(len + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
114 s[len] = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
115 return (char *)memcpy(s,b + 1,len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
116 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
117
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
118 /**************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
119 * Print error message and exit.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
120 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
121
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
122 void error(const char *format, ...)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
123 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
124 va_list ap;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
125
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
126 va_start(ap, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
127 printf("Error: ");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
128 vprintf(format, ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
129 va_end( ap );
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
130 printf("\n");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
131 fflush(stdout);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
132
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
133 exit(EXIT_FAILURE);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
134 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
135
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
136 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
137 void error(const dchar *format, ...)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
138 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
139 va_list ap;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
140
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
141 va_start(ap, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
142 printf("Error: ");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
143 vwprintf(format, ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
144 va_end( ap );
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
145 printf("\n");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
146 fflush(stdout);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
147
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
148 exit(EXIT_FAILURE);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
149 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
150 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
151
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
152 void error_mem()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
153 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
154 error("out of memory");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
155 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
156
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
157 /**************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
158 * Print warning message.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
159 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
160
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
161 void warning(const char *format, ...)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
162 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
163 va_list ap;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
164
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
165 va_start(ap, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
166 printf("Warning: ");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
167 vprintf(format, ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
168 va_end( ap );
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
169 printf("\n");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
170 fflush(stdout);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
171 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
172
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
173 /****************************** Object ********************************/
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
174
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
175 int Object::equals(Object *o)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
176 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
177 return o == this;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
178 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
179
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
180 hash_t Object::hashCode()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
181 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
182 return (hash_t) this;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
183 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
184
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
185 int Object::compare(Object *obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
186 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
187 return this - obj;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
188 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
189
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
190 void Object::print()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
191 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
192 printf("%s %p\n", toChars(), this);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
193 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
194
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
195 char *Object::toChars()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
196 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
197 return (char *)"Object";
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
198 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
199
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
200 dchar *Object::toDchars()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
201 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
202 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
203 return L"Object";
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
204 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
205 return toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
206 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
207 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
208
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
209 int Object::dyncast()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
210 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
211 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
212 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
213
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
214 void Object::toBuffer(OutBuffer *b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
215 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
216 b->writestring("Object");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
217 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
218
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
219 void Object::mark()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
220 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
221 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
222
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
223 /****************************** String ********************************/
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
224
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
225 String::String(char *str, int ref)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
226 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
227 this->str = ref ? str : mem.strdup(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
228 this->ref = ref;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
229 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
230
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
231 String::~String()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
232 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
233 mem.free(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
234 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
235
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
236 void String::mark()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
237 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
238 mem.mark(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
239 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
240
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
241 hash_t String::calcHash(const char *str, size_t len)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
242 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
243 hash_t hash = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
244
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
245 for (;;)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
246 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
247 switch (len)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
248 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
249 case 0:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
250 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
251
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
252 case 1:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
253 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
254 hash += *(uint8_t *)str;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
255 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
256
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
257 case 2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
258 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
259 hash += *(uint16_t *)str;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
260 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
261
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
262 case 3:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
263 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
264 hash += (*(uint16_t *)str << 8) +
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
265 ((uint8_t *)str)[2];
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
266 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
267
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
268 default:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
269 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
270 hash += *(uint32_t *)str;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
271 str += 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
272 len -= 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
273 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
274 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
275 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
276 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
277
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
278 hash_t String::calcHash(const char *str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
279 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
280 return calcHash(str, strlen(str));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
281 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
282
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
283 hash_t String::hashCode()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
284 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
285 return calcHash(str, strlen(str));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
286 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
287
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
288 unsigned String::len()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
289 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
290 return strlen(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
291 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
292
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
293 int String::equals(Object *obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
294 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
295 return strcmp(str,((String *)obj)->str) == 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
296 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
297
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
298 int String::compare(Object *obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
299 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
300 return strcmp(str,((String *)obj)->str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
301 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
302
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
303 char *String::toChars()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
304 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
305 return str;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
306 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
307
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
308 void String::print()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
309 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
310 printf("String '%s'\n",str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
311 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
312
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
313
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
314 /****************************** FileName ********************************/
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
315
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
316 FileName::FileName(char *str, int ref)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
317 : String(str,ref)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
318 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
319 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
320
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
321 char *FileName::combine(const char *path, const char *name)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
322 { char *f;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
323 size_t pathlen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
324 size_t namelen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
325
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
326 if (!path || !*path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
327 return (char *)name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
328 pathlen = strlen(path);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
329 namelen = strlen(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
330 f = (char *)mem.malloc(pathlen + 1 + namelen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
331 memcpy(f, path, pathlen);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
332
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
333 if (
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
334 path[pathlen - 1] != '/'
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
335 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
336 && path[pathlen - 1] != '\\' && path[pathlen - 1] != ':'
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
337 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
338 )
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
339 { f[pathlen] = '/';
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
340 pathlen++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
341 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
342
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
343 memcpy(f + pathlen, name, namelen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
344 return f;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
345 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
346
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
347 FileName::FileName(char *path, char *name)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
348 : String(combine(path,name),1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
349 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
350 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
351
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
352 // Split a path into an Array of paths
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
353 Array *FileName::splitPath(const char *path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
354 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
355 char c = 0; // unnecessary initializer is for VC /W4
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
356 const char *p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
357 OutBuffer buf;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
358 Array *array;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
359
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
360 array = new Array();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
361 if (path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
362 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
363 p = path;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
364 do
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
365 { char instring = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
366
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
367 while (isspace(*p)) // skip leading whitespace
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
368 p++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
369 buf.reserve(strlen(p) + 1); // guess size of path
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
370 // LDC remember first character
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
371 const char* start = p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
372 for (; ; p++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
373 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
374 c = *p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
375 switch (c)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
376 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
377 case '"':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
378 instring ^= 1; // toggle inside/outside of string
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
379 continue;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
380
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
381 #if MACINTOSH
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
382 case ',':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
383 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
384 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
385 case ';':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
386 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
387 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
388 case ':':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
389 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
390 p++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
391 break; // note that ; cannot appear as part
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
392 // of a path, quotes won't protect it
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
393
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
394 case 0x1A: // ^Z means end of file
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
395 case 0:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
396 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
397
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
398 case '\r':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
399 continue; // ignore carriage returns
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
400
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
401 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
402 case '~':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
403 // LDC don't expand unless first character of path
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
404 if (p != start)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
405 goto Ldefault;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
406 buf.writestring(getenv("HOME"));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
407 continue;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
408 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
409
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
410 case ' ':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
411 case '\t': // tabs in filenames?
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
412 if (!instring) // if not in string
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
413 break; // treat as end of path
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
414 default:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
415 Ldefault:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
416 buf.writeByte(c);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
417 continue;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
418 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
419 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
420 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
421 if (buf.offset) // if path is not empty
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
422 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
423 buf.writeByte(0); // to asciiz
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
424 array->push(buf.extractData());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
425 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
426 } while (c);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
427 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
428 return array;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
429 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
430
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
431 hash_t FileName::hashCode()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
432 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
433 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
434 // We need a different hashCode because it must be case-insensitive
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
435 size_t len = strlen(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
436 hash_t hash = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
437 unsigned char *s = (unsigned char *)str;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
438
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
439 for (;;)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
440 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
441 switch (len)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
442 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
443 case 0:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
444 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
445
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
446 case 1:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
447 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
448 hash += *(uint8_t *)s | 0x20;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
449 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
450
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
451 case 2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
452 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
453 hash += *(uint16_t *)s | 0x2020;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
454 return hash;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
455
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
456 case 3:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
457 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
458 hash += ((*(uint16_t *)s << 8) +
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
459 ((uint8_t *)s)[2]) | 0x202020;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
460 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
461
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
462 default:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
463 hash *= 37;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
464 hash += *(uint32_t *)s | 0x20202020;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
465 s += 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
466 len -= 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
467 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
468 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
469 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
470 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
471 // darwin HFS is case insensitive, though...
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
472 return String::hashCode();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
473 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
474 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
475
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
476 int FileName::compare(Object *obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
477 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
478 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
479 return stricmp(str,((FileName *)obj)->str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
480 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
481 return String::compare(obj);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
482 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
483 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
484
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
485 int FileName::equals(Object *obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
486 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
487 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
488 return stricmp(str,((FileName *)obj)->str) == 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
489 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
490 return String::equals(obj);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
491 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
492 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
493
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
494 /************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
495 * Return !=0 if absolute path name.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
496 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
497
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
498 int FileName::absolute(const char *name)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
499 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
500 return
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
501 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
502 (*name == '\\') ||
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
503 (*name == '/') ||
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
504 (*name && name[1] == ':') ||
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
505 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
506 (*name == '/');
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
507 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
508
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
509 /********************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
510 * Return filename extension (read-only).
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
511 * Points past '.' of extension.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
512 * If there isn't one, return NULL.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
513 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
514
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
515 char *FileName::ext(const char *str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
516 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
517 char *e;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
518 size_t len = strlen(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
519
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
520 e = (char *)str + len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
521 for (;;)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
522 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
523 switch (*e)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
524 { case '.':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
525 return e + 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
526
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
527 case '/':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
528 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
529
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
530 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
531 case '\\':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
532 case ':':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
533 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
534 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
535 default:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
536 if (e == str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
537 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
538 e--;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
539 continue;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
540 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
541 return NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
542 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
543 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
544
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
545 char *FileName::ext()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
546 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
547 return ext(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
548 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
549
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
550 /********************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
551 * Return mem.malloc'd filename with extension removed.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
552 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
553
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
554 char *FileName::removeExt(const char *str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
555 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
556 const char *e = ext(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
557 if (e)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
558 { size_t len = (e - str) - 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
559 char *n = (char *)mem.malloc(len + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
560 memcpy(n, str, len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
561 n[len] = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
562 return n;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
563 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
564 return mem.strdup(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
565 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
566
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
567 /********************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
568 * Return filename name excluding path (read-only).
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
569 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
570
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
571 char *FileName::name(const char *str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
572 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
573 char *e;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
574 size_t len = strlen(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
575
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
576 e = (char *)str + len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
577 for (;;)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
578 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
579 switch (*e)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
580 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
581
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
582 case '/':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
583 return e + 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
584
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
585 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
586 case '\\':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
587 case ':':
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
588 return e + 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
589 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
590 default:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
591 if (e == str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
592 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
593 e--;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
594 continue;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
595 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
596 return e;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
597 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
598 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
599
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
600 char *FileName::name()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
601 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
602 return name(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
603 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
604
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
605 /**************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
606 * Return path portion of str.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
607 * Path will does not include trailing path separator.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
608 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
609
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
610 char *FileName::path(const char *str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
611 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
612 char *n = name(str);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
613 char *path;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
614 size_t pathlen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
615
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
616 if (n > str)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
617 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
618
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
619 if (n[-1] == '/')
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
620 n--;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
621
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
622 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
623 if (n[-1] == '\\')
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
624 n--;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
625 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
626 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
627 pathlen = n - str;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
628 path = (char *)mem.malloc(pathlen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
629 memcpy(path, str, pathlen);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
630 path[pathlen] = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
631 return path;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
632 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
633
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
634 /**************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
635 * Replace filename portion of path.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
636 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
637
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
638 char *FileName::replaceName(char *path, char *name)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
639 { char *f;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
640 char *n;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
641 size_t pathlen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
642 size_t namelen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
643
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
644 if (absolute(name))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
645 return name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
646
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
647 n = FileName::name(path);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
648 if (n == path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
649 return name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
650 pathlen = n - path;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
651 namelen = strlen(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
652 f = (char *)mem.malloc(pathlen + 1 + namelen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
653 memcpy(f, path, pathlen);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
654
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
655 if (
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
656 path[pathlen - 1] != '/'
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
657 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
658 && path[pathlen - 1] != '\\' && path[pathlen - 1] != ':'
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
659 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
660 )
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
661 { f[pathlen] = '/';
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
662 pathlen++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
663 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
664
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
665 memcpy(f + pathlen, name, namelen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
666 return f;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
667 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
668
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
669 /***************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
670 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
671
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
672 FileName *FileName::defaultExt(const char *name, const char *ext)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
673 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
674 char *e;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
675 char *s;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
676 size_t len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
677 size_t extlen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
678
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
679 e = FileName::ext(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
680 if (e) // if already has an extension
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
681 return new FileName((char *)name, 0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
682
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
683 len = strlen(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
684 extlen = strlen(ext);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
685 s = (char *)alloca(len + 1 + extlen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
686 memcpy(s,name,len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
687 s[len] = '.';
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
688 memcpy(s + len + 1, ext, extlen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
689 return new FileName(s, 0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
690 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
691
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
692 /***************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
693 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
694
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
695 FileName *FileName::forceExt(const char *name, const char *ext)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
696 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
697 char *e;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
698 char *s;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
699 size_t len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
700 size_t extlen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
701
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
702 e = FileName::ext(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
703 if (e) // if already has an extension
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
704 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
705 len = e - name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
706 extlen = strlen(ext);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
707
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
708 s = (char *)alloca(len + extlen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
709 memcpy(s,name,len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
710 memcpy(s + len, ext, extlen + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
711 return new FileName(s, 0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
712 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
713 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
714 return defaultExt(name, ext); // doesn't have one
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
715 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
716
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
717 /******************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
718 * Return !=0 if extensions match.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
719 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
720
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
721 int FileName::equalsExt(const char *ext)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
722 { const char *e;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
723
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
724 e = FileName::ext();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
725 if (!e && !ext)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
726 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
727 if (!e || !ext)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
728 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
729 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
730 return strcmp(e,ext) == 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
731 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
732 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
733 return stricmp(e,ext) == 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
734 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
735 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
736
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
737 /*************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
738 * Copy file from this to to.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
739 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
740
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
741 void FileName::CopyTo(FileName *to)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
742 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
743 File file(this);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
744
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
745 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
746 file.touchtime = mem.malloc(sizeof(WIN32_FIND_DATAA)); // keep same file time
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
747 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
748 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
749 file.touchtime = mem.malloc(sizeof(struct stat)); // keep same file time
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
750 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
751 file.readv();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
752 file.name = to;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
753 file.writev();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
754 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
755
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
756 /*************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
757 * Search Path for file.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
758 * Input:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
759 * cwd if !=0, search current directory before searching path
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
760 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
761
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
762 char *FileName::searchPath(Array *path, const char *name, int cwd)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
763 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
764 if (absolute(name))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
765 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
766 return exists(name) ? (char *)name : NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
767 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
768 if (cwd)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
769 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
770 if (exists(name))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
771 return (char *)name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
772 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
773 if (path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
774 { unsigned i;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
775
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
776 for (i = 0; i < path->dim; i++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
777 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
778 char *p = (char *)path->data[i];
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
779 char *n = combine(p, name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
780
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
781 if (exists(n))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
782 return n;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
783 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
784 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
785 return NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
786 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
787
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
788 int FileName::exists(const char *name)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
789 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
790 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
791 struct stat st;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
792
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
793 if (stat(name, &st) < 0)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
794 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
795 if (S_ISDIR(st.st_mode))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
796 return 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
797 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
798 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
799 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
800 DWORD dw;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
801 int result;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
802
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
803 dw = GetFileAttributesA(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
804 if (dw == -1L)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
805 result = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
806 else if (dw & FILE_ATTRIBUTE_DIRECTORY)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
807 result = 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
808 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
809 result = 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
810 return result;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
811 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
812 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
813
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
814 void FileName::ensurePathExists(const char *path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
815 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
816 //printf("FileName::ensurePathExists(%s)\n", path ? path : "");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
817 if (path && *path)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
818 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
819 if (!exists(path))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
820 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
821 char *p = FileName::path(path);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
822 if (*p)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
823 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
824 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
825 size_t len = strlen(p);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
826 if (len > 2 && p[-1] == ':')
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
827 { mem.free(p);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
828 return;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
829 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
830 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
831 ensurePathExists(p);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
832 mem.free(p);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
833 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
834 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
835 if (path[strlen(path) - 1] != '\\')
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
836 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
837 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
838 if (path[strlen(path) - 1] != '\\')
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
839 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
840 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
841 //printf("mkdir(%s)\n", path);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
842 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
843 if (mkdir(path))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
844 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
845 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
846 if (mkdir(path, 0777))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
847 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
848 error("cannot create directory %s", path);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
849 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
850 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
851 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
852 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
853
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
854 /****************************** File ********************************/
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
855
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
856 File::File(FileName *n)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
857 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
858 ref = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
859 buffer = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
860 len = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
861 touchtime = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
862 name = n;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
863 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
864
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
865 File::File(char *n)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
866 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
867 ref = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
868 buffer = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
869 len = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
870 touchtime = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
871 name = new FileName(n, 0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
872 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
873
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
874 File::~File()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
875 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
876 if (buffer)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
877 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
878 if (ref == 0)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
879 mem.free(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
880 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
881 else if (ref == 2)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
882 UnmapViewOfFile(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
883 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
884 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
885 if (touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
886 mem.free(touchtime);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
887 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
888
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
889 void File::mark()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
890 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
891 mem.mark(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
892 mem.mark(touchtime);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
893 mem.mark(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
894 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
895
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
896 /*************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
897 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
898
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
899 int File::read()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
900 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
901 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
902 off_t size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
903 ssize_t numread;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
904 int fd;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
905 struct stat buf;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
906 int result = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
907 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
908
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
909 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
910 //printf("File::read('%s')\n",name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
911 fd = open(name, O_RDONLY);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
912 if (fd == -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
913 { result = errno;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
914 //printf("\topen error, errno = %d\n",errno);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
915 goto err1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
916 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
917
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
918 if (!ref)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
919 mem.free(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
920 ref = 0; // we own the buffer now
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
921
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
922 //printf("\tfile opened\n");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
923 if (fstat(fd, &buf))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
924 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
925 printf("\tfstat error, errno = %d\n",errno);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
926 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
927 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
928 size = buf.st_size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
929 buffer = (unsigned char *) mem.malloc(size + 2);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
930 if (!buffer)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
931 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
932 printf("\tmalloc error, errno = %d\n",errno);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
933 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
934 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
935
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
936 numread = ::read(fd, buffer, size);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
937 if (numread != size)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
938 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
939 printf("\tread error, errno = %d\n",errno);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
940 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
941 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
942
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
943 if (touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
944 memcpy(touchtime, &buf, sizeof(buf));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
945
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
946 if (close(fd) == -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
947 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
948 printf("\tclose error, errno = %d\n",errno);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
949 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
950 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
951
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
952 len = size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
953
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
954 // Always store a wchar ^Z past end of buffer so scanner has a sentinel
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
955 buffer[size] = 0; // ^Z is obsolete, use 0
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
956 buffer[size + 1] = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
957 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
958
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
959 err2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
960 close(fd);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
961 err:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
962 mem.free(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
963 buffer = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
964 len = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
965
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
966 err1:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
967 result = 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
968 return result;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
969 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
970 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
971 DWORD size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
972 DWORD numread;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
973 HANDLE h;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
974 int result = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
975 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
976
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
977 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
978 h = CreateFileA(name,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
979 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
980 if (h == INVALID_HANDLE_VALUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
981 goto err1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
982
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
983 if (!ref)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
984 mem.free(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
985 ref = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
986
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
987 size = GetFileSize(h,NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
988 buffer = (unsigned char *) mem.malloc(size + 2);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
989 if (!buffer)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
990 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
991
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
992 if (ReadFile(h,buffer,size,&numread,NULL) != TRUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
993 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
994
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
995 if (numread != size)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
996 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
997
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
998 if (touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
999 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1000 if (!GetFileTime(h, NULL, NULL, &((WIN32_FIND_DATAA *)touchtime)->ftLastWriteTime))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1001 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1002 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1003
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1004 if (!CloseHandle(h))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1005 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1006
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1007 len = size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1008
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1009 // Always store a wchar ^Z past end of buffer so scanner has a sentinel
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1010 buffer[size] = 0; // ^Z is obsolete, use 0
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1011 buffer[size + 1] = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1012 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1013
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1014 err2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1015 CloseHandle(h);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1016 err:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1017 mem.free(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1018 buffer = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1019 len = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1020
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1021 err1:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1022 result = 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1023 return result;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1024 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1025 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1026
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1027 /*****************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1028 * Read a file with memory mapped file I/O.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1029 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1030
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1031 int File::mmread()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1032 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1033 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1034 return read();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1035 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1036 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1037 HANDLE hFile;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1038 HANDLE hFileMap;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1039 DWORD size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1040 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1041
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1042 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1043 hFile = CreateFile(name, GENERIC_READ,
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1044 FILE_SHARE_READ, NULL,
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1045 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1046 if (hFile == INVALID_HANDLE_VALUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1047 goto Lerr;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1048 size = GetFileSize(hFile, NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1049 //printf(" file created, size %d\n", size);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1050
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1051 hFileMap = CreateFileMapping(hFile,NULL,PAGE_READONLY,0,size,NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1052 if (CloseHandle(hFile) != TRUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1053 goto Lerr;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1054
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1055 if (hFileMap == NULL)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1056 goto Lerr;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1057
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1058 //printf(" mapping created\n");
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1059
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1060 if (!ref)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1061 mem.free(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1062 ref = 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1063 buffer = (unsigned char *)MapViewOfFileEx(hFileMap, FILE_MAP_READ,0,0,size,NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1064 if (CloseHandle(hFileMap) != TRUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1065 goto Lerr;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1066 if (buffer == NULL) // mapping view failed
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1067 goto Lerr;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1068
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1069 len = size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1070 //printf(" buffer = %p\n", buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1071
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1072 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1073
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1074 Lerr:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1075 return GetLastError(); // failure
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1076 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1077 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1078
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1079 /*********************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1080 * Write a file.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1081 * Returns:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1082 * 0 success
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1083 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1084
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1085 int File::write()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1086 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1087 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1088 int fd;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1089 ssize_t numwritten;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1090 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1091
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1092 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1093 fd = open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1094 if (fd == -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1095 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1096
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1097 numwritten = ::write(fd, buffer, len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1098 if (len != numwritten)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1099 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1100
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1101 if (close(fd) == -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1102 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1103
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1104 if (touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1105 { struct utimbuf ubuf;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1106
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1107 ubuf.actime = ((struct stat *)touchtime)->st_atime;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1108 ubuf.modtime = ((struct stat *)touchtime)->st_mtime;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1109 if (utime(name, &ubuf))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1110 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1111 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1112 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1113
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1114 err2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1115 close(fd);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1116 ::remove(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1117 err:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1118 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1119 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1120 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1121 HANDLE h;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1122 DWORD numwritten;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1123 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1124
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1125 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1126 h = CreateFileA(name,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1127 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1128 if (h == INVALID_HANDLE_VALUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1129 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1130
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1131 if (WriteFile(h,buffer,len,&numwritten,NULL) != TRUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1132 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1133
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1134 if (len != numwritten)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1135 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1136
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1137 if (touchtime) {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1138 SetFileTime(h, NULL, NULL, &((WIN32_FIND_DATAA *)touchtime)->ftLastWriteTime);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1139 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1140 if (!CloseHandle(h))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1141 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1142 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1143
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1144 err2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1145 CloseHandle(h);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1146 DeleteFileA(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1147 err:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1148 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1149 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1150 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1151
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1152 /*********************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1153 * Append to a file.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1154 * Returns:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1155 * 0 success
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1156 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1157
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1158 int File::append()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1159 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1160 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1161 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1162 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1163 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1164 HANDLE h;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1165 DWORD numwritten;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1166 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1167
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1168 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1169 h = CreateFileA(name,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1170 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,NULL);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1171 if (h == INVALID_HANDLE_VALUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1172 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1173
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1174 #if 1
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1175 SetFilePointer(h, 0, NULL, FILE_END);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1176 #else // INVALID_SET_FILE_POINTER doesn't seem to have a definition
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1177 if (SetFilePointer(h, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1178 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1179 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1180
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1181 if (WriteFile(h,buffer,len,&numwritten,NULL) != TRUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1182 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1183
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1184 if (len != numwritten)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1185 goto err2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1186
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1187 if (touchtime) {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1188 SetFileTime(h, NULL, NULL, &((WIN32_FIND_DATAA *)touchtime)->ftLastWriteTime);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1189 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1190 if (!CloseHandle(h))
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1191 goto err;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1192 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1193
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1194 err2:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1195 CloseHandle(h);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1196 err:
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1197 return 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1198 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1199 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1200
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1201 /**************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1202 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1203
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1204 void File::readv()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1205 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1206 if (read())
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1207 error("Error reading file '%s'\n",name->toChars());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1208 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1209
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1210 /**************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1211 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1212
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1213 void File::mmreadv()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1214 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1215 if (mmread())
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1216 readv();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1217 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1218
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1219 void File::writev()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1220 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1221 if (write())
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1222 error("Error writing file '%s'\n",name->toChars());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1223 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1224
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1225 void File::appendv()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1226 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1227 if (write())
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1228 error("Error appending to file '%s'\n",name->toChars());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1229 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1230
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1231 /*******************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1232 * Return !=0 if file exists.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1233 * 0: file doesn't exist
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1234 * 1: normal file
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1235 * 2: directory
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1236 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1237
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1238 int File::exists()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1239 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1240 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1241 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1242 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1243 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1244 DWORD dw;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1245 int result;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1246 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1247
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1248 name = this->name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1249 if (touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1250 dw = ((WIN32_FIND_DATAA *)touchtime)->dwFileAttributes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1251 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1252 dw = GetFileAttributesA(name);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1253 if (dw == -1L)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1254 result = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1255 else if (dw & FILE_ATTRIBUTE_DIRECTORY)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1256 result = 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1257 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1258 result = 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1259 return result;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1260 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1261 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1262
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1263 void File::remove()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1264 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1265 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1266 ::remove(this->name->toChars());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1267 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1268 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1269 DeleteFileA(this->name->toChars());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1270 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1271 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1272
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1273 Array *File::match(char *n)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1274 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1275 return match(new FileName(n, 0));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1276 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1277
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1278 Array *File::match(FileName *n)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1279 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1280 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1281 return NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1282 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1283 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1284 HANDLE h;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1285 WIN32_FIND_DATAA fileinfo;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1286 Array *a;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1287 char *c;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1288 char *name;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1289
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1290 a = new Array();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1291 c = n->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1292 name = n->name();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1293 h = FindFirstFileA(c,&fileinfo);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1294 if (h != INVALID_HANDLE_VALUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1295 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1296 do
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1297 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1298 // Glue path together with name
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1299 char *fn;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1300 File *f;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1301
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1302 fn = (char *)mem.malloc(name - c + strlen(fileinfo.cFileName) + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1303 memcpy(fn, c, name - c);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1304 strcpy(fn + (name - c), fileinfo.cFileName);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1305 f = new File(fn);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1306 f->touchtime = mem.malloc(sizeof(WIN32_FIND_DATAA));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1307 memcpy(f->touchtime, &fileinfo, sizeof(fileinfo));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1308 a->push(f);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1309 } while (FindNextFileA(h,&fileinfo) != FALSE);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1310 FindClose(h);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1311 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1312 return a;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1313 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1314 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1315
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1316 int File::compareTime(File *f)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1317 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1318 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1319 return 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1320 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1321 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1322 if (!touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1323 stat();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1324 if (!f->touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1325 f->stat();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1326 return CompareFileTime(&((WIN32_FIND_DATAA *)touchtime)->ftLastWriteTime, &((WIN32_FIND_DATAA *)f->touchtime)->ftLastWriteTime);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1327 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1328 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1329
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1330 void File::stat()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1331 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1332 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1333 if (!touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1334 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1335 touchtime = mem.calloc(1, sizeof(struct stat));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1336 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1337 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1338 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1339 HANDLE h;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1340
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1341 if (!touchtime)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1342 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1343 touchtime = mem.calloc(1, sizeof(WIN32_FIND_DATAA));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1344 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1345 h = FindFirstFileA(name->toChars(),(WIN32_FIND_DATAA *)touchtime);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1346 if (h != INVALID_HANDLE_VALUE)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1347 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1348 FindClose(h);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1349 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1350 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1351 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1352
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1353 void File::checkoffset(size_t offset, size_t nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1354 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1355 if (offset > len || offset + nbytes > len)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1356 error("Corrupt file '%s': offset x%zx off end of file",toChars(),offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1357 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1358
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1359 char *File::toChars()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1360 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1361 return name->toChars();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1362 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1363
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1364
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1365 /************************* OutBuffer *************************/
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1366
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1367 OutBuffer::OutBuffer()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1368 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1369 data = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1370 offset = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1371 size = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1372 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1373
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1374 OutBuffer::~OutBuffer()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1375 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1376 mem.free(data);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1377 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1378
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1379 void *OutBuffer::extractData()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1380 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1381 void *p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1382
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1383 p = (void *)data;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1384 data = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1385 offset = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1386 size = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1387 return p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1388 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1389
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1390 void OutBuffer::mark()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1391 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1392 mem.mark(data);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1393 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1394
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1395 void OutBuffer::reserve(unsigned nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1396 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1397 //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1398 if (size - offset < nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1399 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1400 #if defined (__x86_64__)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1401 size = (offset + nbytes) * 2 + 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1402 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1403 size = (offset + nbytes) * 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1404 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1405 data = (unsigned char *)mem.realloc(data, size);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1406 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1407 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1408
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1409 void OutBuffer::reset()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1410 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1411 offset = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1412 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1413
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1414 void OutBuffer::setsize(unsigned size)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1415 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1416 offset = size;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1417 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1418
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1419 void OutBuffer::write(const void *data, unsigned nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1420 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1421 reserve(nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1422 memcpy(this->data + offset, data, nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1423 offset += nbytes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1424 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1425
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1426 void OutBuffer::writebstring(unsigned char *string)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1427 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1428 write(string,*string + 1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1429 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1430
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1431 void OutBuffer::writestring(const char *string)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1432 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1433 write(string,strlen(string));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1434 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1435
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1436 void OutBuffer::writedstring(const char *string)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1437 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1438 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1439 for (; *string; string++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1440 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1441 writedchar(*string);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1442 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1443 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1444 write(string,strlen(string));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1445 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1446 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1447
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1448 void OutBuffer::writedstring(const wchar_t *string)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1449 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1450 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1451 write(string,wcslen(string) * sizeof(wchar_t));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1452 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1453 for (; *string; string++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1454 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1455 writedchar(*string);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1456 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1457 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1458 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1459
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1460 void OutBuffer::prependstring(const char *string)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1461 { unsigned len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1462
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1463 len = strlen(string);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1464 reserve(len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1465 memmove(data + len, data, offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1466 memcpy(data, string, len);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1467 offset += len;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1468 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1469
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1470 void OutBuffer::writenl()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1471 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1472 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1473 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1474 write4(0x000A000D); // newline is CR,LF on Microsoft OS's
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1475 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1476 writeword(0x0A0D); // newline is CR,LF on Microsoft OS's
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1477 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1478 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1479 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1480 writeword('\n');
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1481 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1482 writeByte('\n');
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1483 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1484 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1485 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1486
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1487 void OutBuffer::writeByte(unsigned b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1488 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1489 reserve(1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1490 this->data[offset] = (unsigned char)b;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1491 offset++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1492 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1493
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1494 void OutBuffer::writeUTF8(unsigned b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1495 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1496 reserve(6);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1497 if (b <= 0x7F)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1498 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1499 this->data[offset] = (unsigned char)b;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1500 offset++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1501 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1502 else if (b <= 0x7FF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1503 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1504 this->data[offset + 0] = (unsigned char)((b >> 6) | 0xC0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1505 this->data[offset + 1] = (unsigned char)((b & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1506 offset += 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1507 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1508 else if (b <= 0xFFFF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1509 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1510 this->data[offset + 0] = (unsigned char)((b >> 12) | 0xE0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1511 this->data[offset + 1] = (unsigned char)(((b >> 6) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1512 this->data[offset + 2] = (unsigned char)((b & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1513 offset += 3;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1514 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1515 else if (b <= 0x1FFFFF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1516 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1517 this->data[offset + 0] = (unsigned char)((b >> 18) | 0xF0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1518 this->data[offset + 1] = (unsigned char)(((b >> 12) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1519 this->data[offset + 2] = (unsigned char)(((b >> 6) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1520 this->data[offset + 3] = (unsigned char)((b & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1521 offset += 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1522 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1523 else if (b <= 0x3FFFFFF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1524 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1525 this->data[offset + 0] = (unsigned char)((b >> 24) | 0xF8);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1526 this->data[offset + 1] = (unsigned char)(((b >> 18) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1527 this->data[offset + 2] = (unsigned char)(((b >> 12) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1528 this->data[offset + 3] = (unsigned char)(((b >> 6) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1529 this->data[offset + 4] = (unsigned char)((b & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1530 offset += 5;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1531 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1532 else if (b <= 0x7FFFFFFF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1533 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1534 this->data[offset + 0] = (unsigned char)((b >> 30) | 0xFC);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1535 this->data[offset + 1] = (unsigned char)(((b >> 24) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1536 this->data[offset + 2] = (unsigned char)(((b >> 18) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1537 this->data[offset + 3] = (unsigned char)(((b >> 12) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1538 this->data[offset + 4] = (unsigned char)(((b >> 6) & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1539 this->data[offset + 5] = (unsigned char)((b & 0x3F) | 0x80);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1540 offset += 6;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1541 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1542 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1543 assert(0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1544 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1545
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1546 void OutBuffer::writedchar(unsigned b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1547 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1548 reserve(Dchar_mbmax * sizeof(dchar));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1549 offset = (unsigned char *)Dchar::put((dchar *)(this->data + offset), (dchar)b) -
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1550 this->data;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1551 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1552
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1553 void OutBuffer::prependbyte(unsigned b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1554 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1555 reserve(1);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1556 memmove(data + 1, data, offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1557 data[0] = (unsigned char)b;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1558 offset++;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1559 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1560
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1561 void OutBuffer::writeword(unsigned w)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1562 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1563 reserve(2);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1564 *(unsigned short *)(this->data + offset) = (unsigned short)w;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1565 offset += 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1566 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1567
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1568 void OutBuffer::writeUTF16(unsigned w)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1569 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1570 reserve(4);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1571 if (w <= 0xFFFF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1572 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1573 *(unsigned short *)(this->data + offset) = (unsigned short)w;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1574 offset += 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1575 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1576 else if (w <= 0x10FFFF)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1577 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1578 *(unsigned short *)(this->data + offset) = (unsigned short)((w >> 10) + 0xD7C0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1579 *(unsigned short *)(this->data + offset + 2) = (unsigned short)((w & 0x3FF) | 0xDC00);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1580 offset += 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1581 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1582 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1583 assert(0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1584 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1585
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1586 void OutBuffer::write4(unsigned w)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1587 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1588 reserve(4);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1589 *(unsigned long *)(this->data + offset) = w;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1590 offset += 4;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1591 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1592
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1593 void OutBuffer::write(OutBuffer *buf)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1594 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1595 if (buf)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1596 { reserve(buf->offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1597 memcpy(data + offset, buf->data, buf->offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1598 offset += buf->offset;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1599 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1600 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1601
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1602 void OutBuffer::write(Object *obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1603 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1604 if (obj)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1605 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1606 writestring(obj->toChars());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1607 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1608 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1609
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1610 void OutBuffer::fill0(unsigned nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1611 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1612 reserve(nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1613 memset(data + offset,0,nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1614 offset += nbytes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1615 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1616
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1617 void OutBuffer::align(unsigned size)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1618 { unsigned nbytes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1619
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1620 nbytes = ((offset + size - 1) & ~(size - 1)) - offset;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1621 fill0(nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1622 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1623
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1624
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1625 ////////////////////////////////////////////////////////////////
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1626 // The compiler shipped with Visual Studio 2005 (and possible
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1627 // other versions) does not support C99 printf format specfiers
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1628 // such as %z and %j
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1629 #if _MSC_VER
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1630 using std::string;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1631 using std::wstring;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1632
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1633 template<typename S>
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1634 inline void
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1635 search_and_replace(S& str, const S& what, const S& replacement)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1636 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1637 assert(!what.empty());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1638 size_t pos = str.find(what);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1639 while (pos != S::npos)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1640 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1641 str.replace(pos, what.size(), replacement);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1642 pos = str.find(what, pos + replacement.size());
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1643 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1644 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1645 #define WORKAROUND_C99_SPECIFIERS_BUG(S,tmp,f) \
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1646 S tmp = f; \
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1647 search_and_replace(fmt, S("%z"), S("%l")); \
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1648 search_and_replace(fmt, S("%j"), S("%i")); \
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1649 f = tmp.c_str();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1650 #else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1651 #define WORKAROUND_C99_SPECIFIERS_BUG(S,tmp,f)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1652 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1653
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1654 void OutBuffer::vprintf(const char *format, va_list args)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1655 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1656 char buffer[128];
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1657 char *p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1658 unsigned psize;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1659 int count;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1660
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1661 WORKAROUND_C99_SPECIFIERS_BUG(string, fmt, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1662
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1663 p = buffer;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1664 psize = sizeof(buffer);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1665 for (;;)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1666 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1667 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1668 count = _vsnprintf(p,psize,format,args);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1669 if (count != -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1670 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1671 psize *= 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1672 #elif POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1673 va_list va;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1674 va_copy(va, args);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1675 /*
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1676 The functions vprintf(), vfprintf(), vsprintf(), vsnprintf()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1677 are equivalent to the functions printf(), fprintf(), sprintf(),
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1678 snprintf(), respectively, except that they are called with a
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1679 va_list instead of a variable number of arguments. These
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1680 functions do not call the va_end macro. Consequently, the value
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1681 of ap is undefined after the call. The application should call
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1682 va_end(ap) itself afterwards.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1683 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1684 count = vsnprintf(p,psize,format,va);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1685 va_end(va);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1686 if (count == -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1687 psize *= 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1688 else if (count >= psize)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1689 psize = count + 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1690 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1691 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1692 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1693 p = (char *) alloca(psize); // buffer too small, try again with larger size
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1694 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1695 write(p,count);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1696 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1697
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1698 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1699 void OutBuffer::vprintf(const wchar_t *format, va_list args)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1700 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1701 dchar buffer[128];
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1702 dchar *p;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1703 unsigned psize;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1704 int count;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1705
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1706 WORKAROUND_C99_SPECIFIERS_BUG(wstring, fmt, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1707
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1708 p = buffer;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1709 psize = sizeof(buffer) / sizeof(buffer[0]);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1710 for (;;)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1711 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1712 #if _WIN32
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1713 count = _vsnwprintf(p,psize,format,args);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1714 if (count != -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1715 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1716 psize *= 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1717 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1718 #if POSIX
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1719 va_list va;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1720 va_copy(va, args);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1721 count = vsnwprintf(p,psize,format,va);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1722 va_end(va);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1723
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1724 if (count == -1)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1725 psize *= 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1726 else if (count >= psize)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1727 psize = count + 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1728 else
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1729 break;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1730 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1731 p = (dchar *) alloca(psize * 2); // buffer too small, try again with larger size
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1732 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1733 write(p,count * 2);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1734 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1735 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1736
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1737 void OutBuffer::printf(const char *format, ...)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1738 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1739 va_list ap;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1740 va_start(ap, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1741 vprintf(format,ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1742 va_end(ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1743 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1744
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1745 #if M_UNICODE
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1746 void OutBuffer::printf(const wchar_t *format, ...)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1747 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1748 va_list ap;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1749 va_start(ap, format);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1750 vprintf(format,ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1751 va_end(ap);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1752 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1753 #endif
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1754
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1755 void OutBuffer::bracket(char left, char right)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1756 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1757 reserve(2);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1758 memmove(data + 1, data, offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1759 data[0] = left;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1760 data[offset + 1] = right;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1761 offset += 2;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1762 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1763
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1764 /******************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1765 * Insert left at i, and right at j.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1766 * Return index just past right.
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1767 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1768
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1769 unsigned OutBuffer::bracket(unsigned i, const char *left, unsigned j, const char *right)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1770 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1771 size_t leftlen = strlen(left);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1772 size_t rightlen = strlen(right);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1773 reserve(leftlen + rightlen);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1774 insert(i, left, leftlen);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1775 insert(j + leftlen, right, rightlen);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1776 return j + leftlen + rightlen;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1777 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1778
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1779 void OutBuffer::spread(unsigned offset, unsigned nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1780 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1781 reserve(nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1782 memmove(data + offset + nbytes, data + offset,
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1783 this->offset - offset);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1784 this->offset += nbytes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1785 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1786
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1787 /****************************************
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1788 * Returns: offset + nbytes
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1789 */
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1790
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1791 unsigned OutBuffer::insert(unsigned offset, const void *p, unsigned nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1792 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1793 spread(offset, nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1794 memmove(data + offset, p, nbytes);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1795 return offset + nbytes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1796 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1797
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1798 void OutBuffer::remove(unsigned offset, unsigned nbytes)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1799 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1800 memmove(data + offset, data + offset + nbytes, this->offset - (offset + nbytes));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1801 this->offset -= nbytes;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1802 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1803
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1804 char *OutBuffer::toChars()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1805 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1806 writeByte(0);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1807 return (char *)data;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1808 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1809
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1810 /********************************* Bits ****************************/
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1811
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1812 Bits::Bits()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1813 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1814 data = NULL;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1815 bitdim = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1816 allocdim = 0;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1817 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1818
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1819 Bits::~Bits()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1820 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1821 mem.free(data);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1822 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1823
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1824 void Bits::mark()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1825 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1826 mem.mark(data);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1827 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1828
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1829 void Bits::resize(unsigned bitdim)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1830 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1831 unsigned allocdim;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1832 unsigned mask;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1833
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1834 allocdim = (bitdim + 31) / 32;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1835 data = (unsigned *)mem.realloc(data, allocdim * sizeof(data[0]));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1836 if (this->allocdim < allocdim)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1837 memset(data + this->allocdim, 0, (allocdim - this->allocdim) * sizeof(data[0]));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1838
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1839 // Clear other bits in last word
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1840 mask = (1 << (bitdim & 31)) - 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1841 if (mask)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1842 data[allocdim - 1] &= ~mask;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1843
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1844 this->bitdim = bitdim;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1845 this->allocdim = allocdim;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1846 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1847
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1848 void Bits::set(unsigned bitnum)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1849 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1850 data[bitnum / 32] |= 1 << (bitnum & 31);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1851 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1852
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1853 void Bits::clear(unsigned bitnum)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1854 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1855 data[bitnum / 32] &= ~(1 << (bitnum & 31));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1856 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1857
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1858 int Bits::test(unsigned bitnum)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1859 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1860 return data[bitnum / 32] & (1 << (bitnum & 31));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1861 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1862
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1863 void Bits::set()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1864 { unsigned mask;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1865
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1866 memset(data, ~0, allocdim * sizeof(data[0]));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1867
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1868 // Clear other bits in last word
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1869 mask = (1 << (bitdim & 31)) - 1;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1870 if (mask)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1871 data[allocdim - 1] &= mask;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1872 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1873
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1874 void Bits::clear()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1875 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1876 memset(data, 0, allocdim * sizeof(data[0]));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1877 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1878
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1879 void Bits::copy(Bits *from)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1880 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1881 assert(bitdim == from->bitdim);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1882 memcpy(data, from->data, allocdim * sizeof(data[0]));
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1883 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1884
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1885 Bits *Bits::clone()
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1886 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1887 Bits *b;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1888
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1889 b = new Bits();
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1890 b->resize(bitdim);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1891 b->copy(this);
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1892 return b;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1893 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1894
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1895 void Bits::sub(Bits *b)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1896 {
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1897 unsigned u;
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1898
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1899 for (u = 0; u < allocdim; u++)
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1900 data[u] &= ~b->data[u];
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1901 }
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1902
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1903
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1904
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1905
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1906
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1907
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1908
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1909
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1910
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1911
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1912
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1913
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1914
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1915
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1916