mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
phobos 0.76
This commit is contained in:
parent
fa1bc52ba2
commit
35a12fec2f
51 changed files with 761 additions and 183 deletions
|
@ -29,6 +29,7 @@ version = MULTI_THREADED; // produce multithreaded version
|
||||||
|
|
||||||
debug (PRINTF) import std.c.stdio;
|
debug (PRINTF) import std.c.stdio;
|
||||||
|
|
||||||
|
import std.c.stdio;
|
||||||
import std.c.stdlib;
|
import std.c.stdlib;
|
||||||
import gcbits;
|
import gcbits;
|
||||||
import std.outofmemory;
|
import std.outofmemory;
|
||||||
|
@ -814,7 +815,7 @@ struct Gcx
|
||||||
}
|
}
|
||||||
if (i + 1 < npools)
|
if (i + 1 < npools)
|
||||||
{
|
{
|
||||||
assert(pool.cmp(pooltable[i + 1]) < 0);
|
assert(pool.opCmp(pooltable[i + 1]) < 0);
|
||||||
}
|
}
|
||||||
else if (i + 1 == npools)
|
else if (i + 1 == npools)
|
||||||
{
|
{
|
||||||
|
@ -1177,7 +1178,7 @@ struct Gcx
|
||||||
// Sort pool into newpooltable[]
|
// Sort pool into newpooltable[]
|
||||||
for (i = 0; i < npools; i++)
|
for (i = 0; i < npools; i++)
|
||||||
{
|
{
|
||||||
if (pool.cmp(newpooltable[i]) < 0)
|
if (pool.opCmp(newpooltable[i]) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memmove(newpooltable + i + 1, newpooltable + i, (npools - i) * (Pool *).size);
|
memmove(newpooltable + i + 1, newpooltable + i, (npools - i) * (Pool *).size);
|
||||||
|
@ -1978,7 +1979,7 @@ struct Pool
|
||||||
* Used for sorting pooltable[]
|
* Used for sorting pooltable[]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmp(Pool *p2)
|
int opCmp(Pool *p2)
|
||||||
{
|
{
|
||||||
return baseAddr - p2.baseAddr;
|
return baseAddr - p2.baseAddr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern (C):
|
||||||
|
|
||||||
int _d_obj_eq(Object o1, Object o2)
|
int _d_obj_eq(Object o1, Object o2)
|
||||||
{
|
{
|
||||||
return o1 === o2 || (o1 && o1.eq(o2));
|
return o1 === o2 || (o1 && o1.opEquals(o2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@ int _d_obj_eq(Object o1, Object o2)
|
||||||
|
|
||||||
int _d_obj_cmp(Object o1, Object o2)
|
int _d_obj_cmp(Object o1, Object o2)
|
||||||
{
|
{
|
||||||
return o1.cmp(o2);
|
return o1.opCmp(o2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
122
linux.mak
122
linux.mak
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
CFLAGS=-O
|
CFLAGS=-O
|
||||||
#CFLAGS=-g
|
#CFLAGS=-g
|
||||||
|
|
||||||
DFLAGS=-O -release
|
DFLAGS=-O -release
|
||||||
#DFLAGS=-unittest
|
#DFLAGS=-unittest
|
||||||
|
|
||||||
|
@ -44,15 +45,16 @@ unittest : unittest.o libphobos.a
|
||||||
unittest.o : unittest.d
|
unittest.o : unittest.d
|
||||||
$(DMD) -c unittest
|
$(DMD) -c unittest
|
||||||
|
|
||||||
OBJS= assert.o deh2.o switch.o complex.o gcstats.o \
|
OBJS= asserterror.o deh2.o switch.o complex.o gcstats.o \
|
||||||
critical.o object.o monitor.o arraycat.o invariant.o \
|
critical.o object.o monitor.o arraycat.o invariant.o \
|
||||||
dmain2.o outofmemory.o aaA.o adi.o file.o \
|
dmain2.o outofmemory.o aaA.o adi.o file.o \
|
||||||
compiler.o system.o moduleinit.o \
|
compiler.o system.o moduleinit.o \
|
||||||
cast.o syserror.o path.o string.o memset.o math.o \
|
cast.o path.o string.o memset.o math.o \
|
||||||
outbuffer.o ctype.o regexp.o random.o linux.o \
|
outbuffer.o ctype.o regexp.o random.o linux.o \
|
||||||
stream.o switcherr.o array.o gc.o \
|
stream.o switcherr.o array.o gc.o \
|
||||||
qsort.o thread.o obj.o utf.o uri.o \
|
qsort.o thread.o obj.o utf.o uri.o \
|
||||||
crc32.o conv.o arraycast.o errno.o alloca.o cmath2.o \
|
crc32.o conv.o arraycast.o errno.o alloca.o cmath2.o \
|
||||||
|
process.o syserror.o \
|
||||||
ti_wchar.o ti_uint.o ti_short.o ti_ushort.o \
|
ti_wchar.o ti_uint.o ti_short.o ti_ushort.o \
|
||||||
ti_byte.o ti_ubyte.o ti_long.o ti_ulong.o ti_ptr.o \
|
ti_byte.o ti_ubyte.o ti_long.o ti_ulong.o ti_ptr.o \
|
||||||
ti_float.o ti_double.o ti_real.o ti_delegate.o \
|
ti_float.o ti_double.o ti_real.o ti_delegate.o \
|
||||||
|
@ -61,12 +63,23 @@ OBJS= assert.o deh2.o switch.o complex.o gcstats.o \
|
||||||
ti_Aa.o ti_AC.o ti_Ag.o ti_Aubyte.o ti_Aushort.o ti_Ashort.o \
|
ti_Aa.o ti_AC.o ti_Ag.o ti_Aubyte.o ti_Aushort.o ti_Ashort.o \
|
||||||
ti_C.o ti_int.o ti_char.o ti_dchar.o ti_Adchar.o \
|
ti_C.o ti_int.o ti_char.o ti_dchar.o ti_Adchar.o \
|
||||||
ti_Aint.o ti_Auint.o ti_Along.o ti_Aulong.o ti_Awchar.o \
|
ti_Aint.o ti_Auint.o ti_Along.o ti_Aulong.o ti_Awchar.o \
|
||||||
date.o dateparse.o llmath.o math2.o
|
date.o dateparse.o llmath.o math2.o Czlib.o Dzlib.o zip.o
|
||||||
|
|
||||||
|
ZLIBOBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \
|
||||||
|
etc/c/zlib/crc32.o etc/c/zlib/gzio.o \
|
||||||
|
etc/c/zlib/uncompr.o etc/c/zlib/deflate.o \
|
||||||
|
etc/c/zlib/trees.o etc/c/zlib/zutil.o \
|
||||||
|
etc/c/zlib/inflate.o etc/c/zlib/infblock.o \
|
||||||
|
etc/c/zlib/inftrees.o etc/c/zlib/infcodes.o \
|
||||||
|
etc/c/zlib/infutil.o etc/c/zlib/inffast.o
|
||||||
|
|
||||||
|
GCOBJS= internal/gc/gc.o internal/gc/gcx.o \
|
||||||
|
internal/gc/gcbits.o internal/gc/gclinux.o
|
||||||
|
|
||||||
#SRC= mars.h switch.d complex.c critical.c minit.asm \
|
#SRC= mars.h switch.d complex.c critical.c minit.asm \
|
||||||
# deh.c object.d gc.d math.d c/stdio.d c/stdlib.d time.d monitor.c \
|
# deh.c object.d gc.d math.d c/stdio.d c/stdlib.d time.d monitor.c \
|
||||||
# arraycat.d string.d windows.d path.d linuxextern.d \
|
# arraycat.d string.d windows.d path.d linuxextern.d \
|
||||||
# invariant.d assert.d regexp.d dmain2.d dateparse.d \
|
# invariant.d asserterror.d regexp.d dmain2.d dateparse.d \
|
||||||
# outofmemory.d syserror.d utf.d uri.d \
|
# outofmemory.d syserror.d utf.d uri.d \
|
||||||
# ctype.d aaA.d adi.d file.d compiler.d system.d \
|
# ctype.d aaA.d adi.d file.d compiler.d system.d \
|
||||||
# moduleinit.d cast.d math.d qsort.d \
|
# moduleinit.d cast.d math.d qsort.d \
|
||||||
|
@ -91,9 +104,9 @@ SRCSTD= std/zlib.d std/zip.d std/stdint.d std/conv.d std/utf.d std/uri.d \
|
||||||
std/gc.d std/math.d std/string.d std/path.d std/date.d \
|
std/gc.d std/math.d std/string.d std/path.d std/date.d \
|
||||||
std/ctype.d std/file.d std/compiler.d std/system.d std/moduleinit.d \
|
std/ctype.d std/file.d std/compiler.d std/system.d std/moduleinit.d \
|
||||||
std/outbuffer.d std/math2.d std/thread.d \
|
std/outbuffer.d std/math2.d std/thread.d \
|
||||||
std/assert.d std/dateparse.d std/outofmemory.d \
|
std/asserterror.d std/dateparse.d std/outofmemory.d \
|
||||||
std/intrinsic.d std/array.d std/switcherr.d \
|
std/intrinsic.d std/array.d std/switcherr.d std/syserror.d \
|
||||||
std/regexp.d std/random.d std/stream.d
|
std/regexp.d std/random.d std/stream.d std/process.d
|
||||||
|
|
||||||
SRCSTDC= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.d
|
SRCSTDC= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.d
|
||||||
|
|
||||||
|
@ -125,7 +138,7 @@ SRCINT= \
|
||||||
internal/dmain2.d internal/cast.d internal/qsort.d internal/deh2.d \
|
internal/dmain2.d internal/cast.d internal/qsort.d internal/deh2.d \
|
||||||
internal/cmath2.d internal/obj.d internal/mars.h
|
internal/cmath2.d internal/obj.d internal/mars.h
|
||||||
|
|
||||||
SRCSTDWIN= std/windows/registry.d std/windows/syserror.d \
|
SRCSTDWIN= std/windows/registry.d \
|
||||||
std/windows/iunknown.d
|
std/windows/iunknown.d
|
||||||
|
|
||||||
SRCSTDCWIN= std/c/windows/windows.d std/c/windows/com.d
|
SRCSTDCWIN= std/c/windows/windows.d std/c/windows/com.d
|
||||||
|
@ -134,44 +147,44 @@ SRCSTDCLINUX= std/c/linux/linux.d std/c/linux/linuxextern.d
|
||||||
|
|
||||||
SRCETC= etc/c/zlib.d
|
SRCETC= etc/c/zlib.d
|
||||||
|
|
||||||
SRCZLIB= etc/c/zlib\algorithm.txt \
|
SRCZLIB= etc/c/zlib/algorithm.txt \
|
||||||
etc/c/zlib\trees.h \
|
etc/c/zlib/trees.h \
|
||||||
etc/c/zlib\inffixed.h \
|
etc/c/zlib/inffixed.h \
|
||||||
etc/c/zlib\INDEX \
|
etc/c/zlib/INDEX \
|
||||||
etc/c/zlib\zconf.h \
|
etc/c/zlib/zconf.h \
|
||||||
etc/c/zlib\compress.c \
|
etc/c/zlib/compress.c \
|
||||||
etc/c/zlib\adler32.c \
|
etc/c/zlib/adler32.c \
|
||||||
etc/c/zlib\uncompr.c \
|
etc/c/zlib/uncompr.c \
|
||||||
etc/c/zlib\deflate.h \
|
etc/c/zlib/deflate.h \
|
||||||
etc/c/zlib\example.c \
|
etc/c/zlib/example.c \
|
||||||
etc/c/zlib\zutil.c \
|
etc/c/zlib/zutil.c \
|
||||||
etc/c/zlib\gzio.c \
|
etc/c/zlib/gzio.c \
|
||||||
etc/c/zlib\crc32.c \
|
etc/c/zlib/crc32.c \
|
||||||
etc/c/zlib\infblock.c \
|
etc/c/zlib/infblock.c \
|
||||||
etc/c/zlib\infblock.h \
|
etc/c/zlib/infblock.h \
|
||||||
etc/c/zlib\infcodes.c \
|
etc/c/zlib/infcodes.c \
|
||||||
etc/c/zlib\infcodes.h \
|
etc/c/zlib/infcodes.h \
|
||||||
etc/c/zlib\inffast.c \
|
etc/c/zlib/inffast.c \
|
||||||
etc/c/zlib\inffast.h \
|
etc/c/zlib/inffast.h \
|
||||||
etc/c/zlib\zutil.h \
|
etc/c/zlib/zutil.h \
|
||||||
etc/c/zlib\inflate.c \
|
etc/c/zlib/inflate.c \
|
||||||
etc/c/zlib\trees.c \
|
etc/c/zlib/trees.c \
|
||||||
etc/c/zlib\inftrees.h \
|
etc/c/zlib/inftrees.h \
|
||||||
etc/c/zlib\infutil.c \
|
etc/c/zlib/infutil.c \
|
||||||
etc/c/zlib\infutil.h \
|
etc/c/zlib/infutil.h \
|
||||||
etc/c/zlib\minigzip.c \
|
etc/c/zlib/minigzip.c \
|
||||||
etc/c/zlib\inftrees.c \
|
etc/c/zlib/inftrees.c \
|
||||||
etc/c/zlib\zlib.html \
|
etc/c/zlib/zlib.html \
|
||||||
etc/c/zlib\maketree.c \
|
etc/c/zlib/maketree.c \
|
||||||
etc/c/zlib\zlib.h \
|
etc/c/zlib/zlib.h \
|
||||||
etc/c/zlib\zlib.3 \
|
etc/c/zlib/zlib.3 \
|
||||||
etc/c/zlib\FAQ \
|
etc/c/zlib/FAQ \
|
||||||
etc/c/zlib\deflate.c \
|
etc/c/zlib/deflate.c \
|
||||||
etc/c/zlib\ChangeLog \
|
etc/c/zlib/ChangeLog \
|
||||||
etc/c/zlib\win32.mak \
|
etc/c/zlib/win32.mak \
|
||||||
etc/c/zlib\linux.mak \
|
etc/c/zlib/linux.mak \
|
||||||
etc/c/zlib\zlib.lib \
|
etc/c/zlib/zlib.lib \
|
||||||
etc/c/zlib\README
|
etc/c/zlib/README
|
||||||
|
|
||||||
SRCGC= internal/gc/gc.d \
|
SRCGC= internal/gc/gc.d \
|
||||||
internal/gc/gcx.d \
|
internal/gc/gcx.d \
|
||||||
|
@ -187,8 +200,7 @@ ALLSRCS = $(SRC) $(SRCSTD) $(SRCSTDC) $(SRCTI) $(SRCINT) $(SRCSTDWIN) \
|
||||||
|
|
||||||
|
|
||||||
libphobos.a : $(OBJS) internal/gc/dmgc.a linux.mak
|
libphobos.a : $(OBJS) internal/gc/dmgc.a linux.mak
|
||||||
ar -r $@ $(OBJS) internal/gc/gc.o internal/gc/gcx.o \
|
ar -r $@ $(OBJS) $(ZLIBOBJS) $(GCOBJS)
|
||||||
internal/gc/gcbits.o internal/gc/gclinux.o
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
|
@ -267,8 +279,8 @@ switch.o : internal/switch.d
|
||||||
array.o : std/array.d
|
array.o : std/array.d
|
||||||
$(DMD) -c $(DFLAGS) std/array.d
|
$(DMD) -c $(DFLAGS) std/array.d
|
||||||
|
|
||||||
assert.o : std/assert.d
|
asserterror.o : std/asserterror.d
|
||||||
$(DMD) -c $(DFLAGS) std/assert.d
|
$(DMD) -c $(DFLAGS) std/asserterror.d
|
||||||
|
|
||||||
compiler.o : std/compiler.d
|
compiler.o : std/compiler.d
|
||||||
$(DMD) -c $(DFLAGS) std/compiler.d
|
$(DMD) -c $(DFLAGS) std/compiler.d
|
||||||
|
@ -312,6 +324,9 @@ outofmemory.o : std/outofmemory.d
|
||||||
path.o : std/path.d
|
path.o : std/path.d
|
||||||
$(DMD) -c $(DFLAGS) std/path.d
|
$(DMD) -c $(DFLAGS) std/path.d
|
||||||
|
|
||||||
|
process.o : std/process.d
|
||||||
|
$(DMD) -c $(DFLAGS) std/process.d
|
||||||
|
|
||||||
random.o : std/random.d
|
random.o : std/random.d
|
||||||
$(DMD) -c $(DFLAGS) std/random.d
|
$(DMD) -c $(DFLAGS) std/random.d
|
||||||
|
|
||||||
|
@ -330,6 +345,9 @@ switcherr.o : std/switcherr.d
|
||||||
system.o : std/system.d
|
system.o : std/system.d
|
||||||
$(DMD) -c $(DFLAGS) std/system.d
|
$(DMD) -c $(DFLAGS) std/system.d
|
||||||
|
|
||||||
|
syserror.o : std/syserror.d
|
||||||
|
$(DMD) -c $(DFLAGS) std/syserror.d
|
||||||
|
|
||||||
thread.o : std/thread.d
|
thread.o : std/thread.d
|
||||||
$(DMD) -c $(DFLAGS) std/thread.d
|
$(DMD) -c $(DFLAGS) std/thread.d
|
||||||
|
|
||||||
|
@ -465,9 +483,9 @@ ti_int.o : std/typeinfo/ti_int.d
|
||||||
|
|
||||||
##########################################################333
|
##########################################################333
|
||||||
|
|
||||||
zip : $(ALLSRCS)
|
zip : $(ALLSRCS) linux.mak win32.mak
|
||||||
rm phobos.zip
|
rm phobos.zip
|
||||||
zip phobos $(ALLSRCS)
|
zip phobos $(ALLSRCS) linux.mak win32.mak
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(OBJS)
|
rm $(OBJS)
|
||||||
|
|
4
object.d
4
object.d
|
@ -21,12 +21,12 @@ class Object
|
||||||
return (uint)(void *)this;
|
return (uint)(void *)this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmp(Object o)
|
int opCmp(Object o)
|
||||||
{
|
{
|
||||||
return (int)(void *)this - (int)(void *)o;
|
return (int)(void *)this - (int)(void *)o;
|
||||||
}
|
}
|
||||||
|
|
||||||
int eq(Object o)
|
int opEquals(Object o)
|
||||||
{
|
{
|
||||||
return this === o;
|
return this === o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
import object;
|
module std.array;
|
||||||
import std.c.stdio;
|
|
||||||
|
private import std.c.stdio;
|
||||||
|
|
||||||
class ArrayBoundsError : Error
|
class ArrayBoundsError : Error
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
import object;
|
module std.assertexception;
|
||||||
import std.c.stdio;
|
|
||||||
|
|
||||||
class Assert : Object
|
class AssertError : Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -18,26 +17,26 @@ class Assert : Object
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
* If nobody catches the Assert, this winds up
|
* If nobody catches the AssertError, this winds up
|
||||||
* getting called by the startup code.
|
* getting called by the startup code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void print()
|
void print()
|
||||||
{
|
{
|
||||||
printf("Assertion Failure %s(%u)\n", (char *)filename, linnum);
|
printf("AssertErrorion Failure %s(%u)\n", (char *)filename, linnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
* Called by the compiler generated module assert function.
|
* Called by the compiler generated module assert function.
|
||||||
* Builds an Assert exception and throws it.
|
* Builds an AssertError exception and throws it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern (C) static void _d_assert(char[] filename, uint line)
|
extern (C) static void _d_assert(char[] filename, uint line)
|
||||||
{
|
{
|
||||||
//printf("_d_assert(%s, %d)\n", (char *)filename, line);
|
//printf("_d_assert(%s, %d)\n", (char *)filename, line);
|
||||||
Assert a = new Assert(filename, line);
|
AssertError a = new AssertError(filename, line);
|
||||||
//printf("assertion %p created\n", a);
|
//printf("assertion %p created\n", a);
|
||||||
throw a;
|
throw a;
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ enum
|
||||||
O_APPEND = 02000,
|
O_APPEND = 02000,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat
|
struct struct_stat // distinguish it from the stat() function
|
||||||
{
|
{
|
||||||
ulong st_dev;
|
ulong st_dev;
|
||||||
ushort __pad1;
|
ushort __pad1;
|
||||||
|
@ -78,9 +78,21 @@ struct stat
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
assert(stat.size == 88);
|
assert(struct_stat.size == 88);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum : int
|
||||||
|
{
|
||||||
|
S_IFIFO = 0010000,
|
||||||
|
S_IFCHR = 0020000,
|
||||||
|
S_IFDIR = 0040000,
|
||||||
|
S_IFBLK = 0060000,
|
||||||
|
S_IFREG = 0100000,
|
||||||
|
S_IFLNK = 0120000,
|
||||||
|
S_IFSOCK = 0140000,
|
||||||
|
|
||||||
|
S_IFMT = 0170000
|
||||||
|
}
|
||||||
|
|
||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
|
@ -89,8 +101,13 @@ extern (C)
|
||||||
int write(int, void*, int);
|
int write(int, void*, int);
|
||||||
int close(int);
|
int close(int);
|
||||||
int lseek(int, int, int);
|
int lseek(int, int, int);
|
||||||
int fstat(int, stat*);
|
int fstat(int, struct_stat*);
|
||||||
|
int stat(char*, struct_stat*);
|
||||||
int getErrno();
|
int getErrno();
|
||||||
|
int chdir(char*);
|
||||||
|
int mkdir(char*, int);
|
||||||
|
int rmdir(char*);
|
||||||
|
char* getcwd(char*, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval
|
struct timeval
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* Put them separate so they'll be externed - do not link in linuxextern.o
|
* Put them separate so they'll be externed - do not link in linuxextern.o
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
module std.c.linux.linuxextern;
|
||||||
|
|
||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
void* __libc_stack_end;
|
void* __libc_stack_end;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
/* Interface to the C header file process.h
|
/* Interface to the C header file process.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
module std.c.process;
|
||||||
|
|
||||||
extern (C):
|
extern (C):
|
||||||
|
|
||||||
void exit(int);
|
void exit(int);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
module std.c.time;
|
||||||
|
|
||||||
extern (C):
|
extern (C):
|
||||||
|
|
||||||
const uint CLOCKS_PER_SEC = 1000;
|
const uint CLOCKS_PER_SEC = 1000;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
import std.c.windows.windows;
|
module std.c.windows.com;
|
||||||
import std.string;
|
|
||||||
|
private import std.c.windows.windows;
|
||||||
|
private import std.string;
|
||||||
|
|
||||||
alias WCHAR OLECHAR;
|
alias WCHAR OLECHAR;
|
||||||
alias OLECHAR *LPOLESTR;
|
alias OLECHAR *LPOLESTR;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
module std.c.windows.windows;
|
||||||
|
|
||||||
extern (Windows)
|
extern (Windows)
|
||||||
{
|
{
|
||||||
alias uint ULONG;
|
alias uint ULONG;
|
||||||
|
@ -22,7 +24,7 @@ extern (Windows)
|
||||||
alias LPSTR PTSTR, LPTSTR;
|
alias LPSTR PTSTR, LPTSTR;
|
||||||
alias LPCSTR LPCTSTR;
|
alias LPCSTR LPCTSTR;
|
||||||
|
|
||||||
alias WCHAR* LPCWSTR, PCWSTR;
|
alias WCHAR* LPWSTR, LPCWSTR, PCWSTR;
|
||||||
|
|
||||||
alias uint DWORD;
|
alias uint DWORD;
|
||||||
alias int BOOL;
|
alias int BOOL;
|
||||||
|
@ -262,8 +264,32 @@ struct WIN32_FIND_DATA {
|
||||||
char cAlternateFileName[ 14 ];
|
char cAlternateFileName[ 14 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct WIN32_FIND_DATAW {
|
||||||
|
DWORD dwFileAttributes;
|
||||||
|
FILETIME ftCreationTime;
|
||||||
|
FILETIME ftLastAccessTime;
|
||||||
|
FILETIME ftLastWriteTime;
|
||||||
|
DWORD nFileSizeHigh;
|
||||||
|
DWORD nFileSizeLow;
|
||||||
|
DWORD dwReserved0;
|
||||||
|
DWORD dwReserved1;
|
||||||
|
WCHAR cFileName[ 260 ];
|
||||||
|
WCHAR cAlternateFileName[ 14 ];
|
||||||
|
}
|
||||||
|
|
||||||
export
|
export
|
||||||
{
|
{
|
||||||
|
BOOL SetCurrentDirectoryA(LPCSTR lpPathName);
|
||||||
|
BOOL SetCurrentDirectoryW(LPCWSTR lpPathName);
|
||||||
|
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer);
|
||||||
|
DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer);
|
||||||
|
BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||||
|
BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||||
|
BOOL CreateDirectoryExA(LPCSTR lpTemplateDirectory, LPCSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||||
|
BOOL CreateDirectoryExW(LPCWSTR lpTemplateDirectory, LPCWSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||||
|
BOOL RemoveDirectoryA(LPCSTR lpPathName);
|
||||||
|
BOOL RemoveDirectoryW(LPCWSTR lpPathName);
|
||||||
|
|
||||||
BOOL CloseHandle(HANDLE hObject);
|
BOOL CloseHandle(HANDLE hObject);
|
||||||
HANDLE CreateFileA(char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
HANDLE CreateFileA(char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||||
SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition,
|
SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
// Identify the compiler used and its various features.
|
// Identify the compiler used and its various features.
|
||||||
|
|
||||||
|
module std.compiler;
|
||||||
|
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
|
|
||||||
// conv.d
|
|
||||||
// Written by Walter Bright
|
// Written by Walter Bright
|
||||||
// Copyright (c) 2002 Digital Mars
|
// Copyright (c) 2002-2003 Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
|
|
||||||
// Conversion building blocks. These differ from the C equivalents by
|
// Conversion building blocks. These differ from the C equivalents by
|
||||||
// checking for overflow and not allowing whitespace.
|
// checking for overflow and not allowing whitespace.
|
||||||
|
|
||||||
|
module std.conv;
|
||||||
|
|
||||||
//debug=conv; // uncomment to turn on debugging printf's
|
//debug=conv; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
// ctype.d
|
|
||||||
// Written by Walter Bright
|
// Written by Walter Bright
|
||||||
// Copyright (c) 2001 Digital Mars
|
// Copyright (c) 2001-2003 Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
|
|
||||||
// Simple char classification functions
|
// Simple char classification functions
|
||||||
|
|
||||||
|
module std.ctype;
|
||||||
|
|
||||||
int isalnum(char c) { return _ctype[1 + c] & (_ALP|_DIG); }
|
int isalnum(char c) { return _ctype[1 + c] & (_ALP|_DIG); }
|
||||||
int isalpha(char c) { return _ctype[1 + c] & (_ALP); }
|
int isalpha(char c) { return _ctype[1 + c] & (_ALP); }
|
||||||
|
|
|
@ -6,9 +6,12 @@
|
||||||
|
|
||||||
module std.dateparse;
|
module std.dateparse;
|
||||||
|
|
||||||
import std.string;
|
private
|
||||||
import std.c.stdlib;
|
{
|
||||||
import std.date;
|
import std.string;
|
||||||
|
import std.c.stdlib;
|
||||||
|
import std.date;
|
||||||
|
}
|
||||||
|
|
||||||
//debug=log;
|
//debug=log;
|
||||||
|
|
||||||
|
|
263
std/file.d
263
std/file.d
|
@ -1,17 +1,20 @@
|
||||||
|
|
||||||
// Copyright (c) 2001-2002 by Digital Mars
|
// Copyright (c) 2001-2003 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
|
|
||||||
|
module std.file;
|
||||||
|
|
||||||
private import std.c.stdio;
|
private import std.c.stdio;
|
||||||
|
private import std.path;
|
||||||
private import std.string;
|
private import std.string;
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FileError : Error
|
class FileException : Exception
|
||||||
{
|
{
|
||||||
private import std.windows.syserror;
|
private import std.syserror;
|
||||||
|
|
||||||
uint errno; // operating system error code
|
uint errno; // operating system error code
|
||||||
|
|
||||||
|
@ -49,7 +52,7 @@ private import std.c.windows.windows;
|
||||||
* array of bytes read
|
* array of bytes read
|
||||||
*/
|
*/
|
||||||
|
|
||||||
byte[] read(char[] name)
|
void[] read(char[] name)
|
||||||
{
|
{
|
||||||
DWORD size;
|
DWORD size;
|
||||||
DWORD numread;
|
DWORD numread;
|
||||||
|
@ -82,7 +85,7 @@ err2:
|
||||||
err:
|
err:
|
||||||
delete buf;
|
delete buf;
|
||||||
err1:
|
err1:
|
||||||
throw new FileError(name, GetLastError());
|
throw new FileException(name, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************
|
/*********************************************
|
||||||
|
@ -91,7 +94,7 @@ err1:
|
||||||
* 0 success
|
* 0 success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void write(char[] name, byte[] buffer)
|
void write(char[] name, void[] buffer)
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
DWORD numwritten;
|
DWORD numwritten;
|
||||||
|
@ -114,7 +117,7 @@ void write(char[] name, byte[] buffer)
|
||||||
err2:
|
err2:
|
||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
err:
|
err:
|
||||||
throw new FileError(name, GetLastError());
|
throw new FileException(name, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +125,7 @@ err:
|
||||||
* Append to a file.
|
* Append to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void append(char[] name, byte[] buffer)
|
void append(char[] name, void[] buffer)
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
DWORD numwritten;
|
DWORD numwritten;
|
||||||
|
@ -147,7 +150,7 @@ void append(char[] name, byte[] buffer)
|
||||||
err2:
|
err2:
|
||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
err:
|
err:
|
||||||
throw new FileError(name, GetLastError());
|
throw new FileException(name, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,7 +164,7 @@ void rename(char[] from, char[] to)
|
||||||
|
|
||||||
result = MoveFileA(toStringz(from), toStringz(to));
|
result = MoveFileA(toStringz(from), toStringz(to));
|
||||||
if (!result)
|
if (!result)
|
||||||
throw new FileError(to, GetLastError());
|
throw new FileException(to, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +178,7 @@ void remove(char[] name)
|
||||||
|
|
||||||
result = DeleteFileA(toStringz(name));
|
result = DeleteFileA(toStringz(name));
|
||||||
if (!result)
|
if (!result)
|
||||||
throw new FileError(name, GetLastError());
|
throw new FileException(name, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +186,7 @@ void remove(char[] name)
|
||||||
* Get file size.
|
* Get file size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint getSize(char[] name)
|
ulong getSize(char[] name)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA filefindbuf;
|
WIN32_FIND_DATA filefindbuf;
|
||||||
HANDLE findhndl;
|
HANDLE findhndl;
|
||||||
|
@ -191,7 +194,7 @@ uint getSize(char[] name)
|
||||||
findhndl = FindFirstFileA(toStringz(name), &filefindbuf);
|
findhndl = FindFirstFileA(toStringz(name), &filefindbuf);
|
||||||
if (findhndl == (HANDLE)-1)
|
if (findhndl == (HANDLE)-1)
|
||||||
{
|
{
|
||||||
throw new FileError(name, GetLastError());
|
throw new FileException(name, GetLastError());
|
||||||
}
|
}
|
||||||
FindClose(findhndl);
|
FindClose(findhndl);
|
||||||
return filefindbuf.nFileSizeLow;
|
return filefindbuf.nFileSizeLow;
|
||||||
|
@ -209,7 +212,120 @@ uint getAttributes(char[] name)
|
||||||
result = GetFileAttributesA(toStringz(name));
|
result = GetFileAttributesA(toStringz(name));
|
||||||
if (result == 0xFFFFFFFF)
|
if (result == 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
throw new FileError(name, GetLastError());
|
throw new FileException(name, GetLastError());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Is name a file?
|
||||||
|
*/
|
||||||
|
|
||||||
|
int isfile(char[] name)
|
||||||
|
{
|
||||||
|
return (getAttributes(name) & FILE_ATTRIBUTE_DIRECTORY) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Is name a directory?
|
||||||
|
*/
|
||||||
|
|
||||||
|
int isdir(char[] name)
|
||||||
|
{
|
||||||
|
return (getAttributes(name) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Change directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void chdir(char[] pathname)
|
||||||
|
{
|
||||||
|
if (!SetCurrentDirectoryA(toStringz(pathname)))
|
||||||
|
{
|
||||||
|
throw new FileException(pathname, GetLastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Make directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mkdir(char[] pathname)
|
||||||
|
{
|
||||||
|
if (!CreateDirectoryA(toStringz(pathname), null))
|
||||||
|
{
|
||||||
|
throw new FileException(pathname, GetLastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Remove directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void rmdir(char[] pathname)
|
||||||
|
{
|
||||||
|
if (!RemoveDirectoryA(toStringz(pathname)))
|
||||||
|
{
|
||||||
|
throw new FileException(pathname, GetLastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Get current directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char[] getcwd()
|
||||||
|
{
|
||||||
|
char[] dir;
|
||||||
|
int length;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
length = GetCurrentDirectoryA(0, &c);
|
||||||
|
if (!length)
|
||||||
|
{
|
||||||
|
throw new FileException("getcwd", GetLastError());
|
||||||
|
}
|
||||||
|
dir = new char[length];
|
||||||
|
length = GetCurrentDirectoryA(length, dir);
|
||||||
|
if (!length)
|
||||||
|
{
|
||||||
|
throw new FileException("getcwd", GetLastError());
|
||||||
|
}
|
||||||
|
return dir[0 .. length]; // leave off terminating 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************
|
||||||
|
* Return contents of directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char[][] listdir(char[] pathname)
|
||||||
|
{
|
||||||
|
char[][] result;
|
||||||
|
char[] c;
|
||||||
|
HANDLE h;
|
||||||
|
WIN32_FIND_DATA fileinfo;
|
||||||
|
|
||||||
|
c = std.path.join(pathname, "*.*");
|
||||||
|
h = FindFirstFileA(toStringz(c), &fileinfo);
|
||||||
|
if (h != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{ int i;
|
||||||
|
int clength;
|
||||||
|
|
||||||
|
// Skip "." and ".."
|
||||||
|
if (std.string.strcmp(fileinfo.cFileName, ".") == 0 ||
|
||||||
|
std.string.strcmp(fileinfo.cFileName, "..") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
i = result.length;
|
||||||
|
result.length = i + 1;
|
||||||
|
clength = std.string.strlen(fileinfo.cFileName);
|
||||||
|
result[i] = new char[clength];
|
||||||
|
result[i][] = fileinfo.cFileName[0 .. clength];
|
||||||
|
} while (FindNextFileA(h,&fileinfo) != FALSE);
|
||||||
|
FindClose(h);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -229,12 +345,12 @@ private import std.c.linux.linux;
|
||||||
* array of bytes read
|
* array of bytes read
|
||||||
*/
|
*/
|
||||||
|
|
||||||
byte[] read(char[] name)
|
void[] read(char[] name)
|
||||||
{
|
{
|
||||||
uint size;
|
uint size;
|
||||||
uint numread;
|
uint numread;
|
||||||
int fd;
|
int fd;
|
||||||
stat statbuf;
|
struct_stat statbuf;
|
||||||
byte[] buf;
|
byte[] buf;
|
||||||
char *namez;
|
char *namez;
|
||||||
|
|
||||||
|
@ -277,7 +393,7 @@ err:
|
||||||
delete buf;
|
delete buf;
|
||||||
|
|
||||||
err1:
|
err1:
|
||||||
throw new FileError(name, getErrno());
|
throw new FileException(name, getErrno());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************
|
/*********************************************
|
||||||
|
@ -286,7 +402,7 @@ err1:
|
||||||
* 0 success
|
* 0 success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void write(char[] name, byte[] buffer)
|
void write(char[] name, void[] buffer)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int numwritten;
|
int numwritten;
|
||||||
|
@ -309,7 +425,7 @@ void write(char[] name, byte[] buffer)
|
||||||
err2:
|
err2:
|
||||||
std.c.linux.linux.close(fd);
|
std.c.linux.linux.close(fd);
|
||||||
err:
|
err:
|
||||||
throw new FileError(name, getErrno());
|
throw new FileException(name, getErrno());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,7 +433,7 @@ err:
|
||||||
* Append to a file.
|
* Append to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void append(char[] name, byte[] buffer)
|
void append(char[] name, void[] buffer)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int numwritten;
|
int numwritten;
|
||||||
|
@ -340,7 +456,7 @@ void append(char[] name, byte[] buffer)
|
||||||
err2:
|
err2:
|
||||||
std.c.linux.linux.close(fd);
|
std.c.linux.linux.close(fd);
|
||||||
err:
|
err:
|
||||||
throw new FileError(name, getErrno());
|
throw new FileException(name, getErrno());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,7 +470,7 @@ void rename(char[] from, char[] to)
|
||||||
char *toz = toStringz(to);
|
char *toz = toStringz(to);
|
||||||
|
|
||||||
if (std.c.stdio.rename(fromz, toz) == -1)
|
if (std.c.stdio.rename(fromz, toz) == -1)
|
||||||
throw new FileError(to, getErrno());
|
throw new FileException(to, getErrno());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -365,7 +481,7 @@ void rename(char[] from, char[] to)
|
||||||
void remove(char[] name)
|
void remove(char[] name)
|
||||||
{
|
{
|
||||||
if (std.c.stdio.remove(toStringz(name)) == -1)
|
if (std.c.stdio.remove(toStringz(name)) == -1)
|
||||||
throw new FileError(name, getErrno());
|
throw new FileException(name, getErrno());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,11 +489,11 @@ void remove(char[] name)
|
||||||
* Get file size.
|
* Get file size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint getSize(char[] name)
|
ulong getSize(char[] name)
|
||||||
{
|
{
|
||||||
uint size;
|
uint size;
|
||||||
int fd;
|
int fd;
|
||||||
stat statbuf;
|
struct_stat statbuf;
|
||||||
char *namez;
|
char *namez;
|
||||||
|
|
||||||
namez = toStringz(name);
|
namez = toStringz(name);
|
||||||
|
@ -409,7 +525,7 @@ err2:
|
||||||
std.c.linux.linux.close(fd);
|
std.c.linux.linux.close(fd);
|
||||||
err:
|
err:
|
||||||
err1:
|
err1:
|
||||||
throw new FileError(name, getErrno());
|
throw new FileException(name, getErrno());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -419,7 +535,100 @@ err1:
|
||||||
|
|
||||||
uint getAttributes(char[] name)
|
uint getAttributes(char[] name)
|
||||||
{
|
{
|
||||||
return 0;
|
struct_stat statbuf;
|
||||||
|
char *namez;
|
||||||
|
|
||||||
|
namez = toStringz(name);
|
||||||
|
if (std.c.linux.linux.stat(namez, &statbuf))
|
||||||
|
{
|
||||||
|
throw new FileException(name, getErrno());
|
||||||
|
}
|
||||||
|
|
||||||
|
return statbuf.st_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Is name a file?
|
||||||
|
*/
|
||||||
|
|
||||||
|
int isfile(char[] name)
|
||||||
|
{
|
||||||
|
return getAttributes(name) & S_IFREG; // regular file
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Is name a directory?
|
||||||
|
*/
|
||||||
|
|
||||||
|
int isdir(char[] name)
|
||||||
|
{
|
||||||
|
return getAttributes(name) & S_IFDIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Change directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void chdir(char[] pathname)
|
||||||
|
{
|
||||||
|
if (std.c.linux.linux.chdir(toStringz(pathname)) == 0)
|
||||||
|
{
|
||||||
|
throw new FileException(pathname, getErrno());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Make directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mkdir(char[] pathname)
|
||||||
|
{
|
||||||
|
if (std.c.linux.linux.mkdir(toStringz(pathname), 0777) == 0)
|
||||||
|
{
|
||||||
|
throw new FileException(pathname, getErrno());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Remove directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void rmdir(char[] pathname)
|
||||||
|
{
|
||||||
|
if (std.c.linux.linux.rmdir(toStringz(pathname)) == 0)
|
||||||
|
{
|
||||||
|
throw new FileException(pathname, getErrno());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************
|
||||||
|
* Get current directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char[] getcwd()
|
||||||
|
{ char* p;
|
||||||
|
|
||||||
|
p = std.c.linux.linux.getcwd(null, 0);
|
||||||
|
if (!p)
|
||||||
|
{
|
||||||
|
throw new FileException("cannot get cwd", getErrno());
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = std.string.strlen(p);
|
||||||
|
char[] buf = new char[length];
|
||||||
|
buf[] = p[0 .. length];
|
||||||
|
std.c.stdlib.free(p);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************
|
||||||
|
* Return contents of directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char[][] listdir(char[] pathname)
|
||||||
|
{
|
||||||
|
assert(0); // BUG: not implemented
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
5
std/gc.d
5
std/gc.d
|
@ -1,8 +1,11 @@
|
||||||
// Copyright (c) 1999-2002 by Digital Mars
|
|
||||||
|
// Copyright (c) 1999-2003 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
|
|
||||||
|
module std.gc;
|
||||||
|
|
||||||
import gcstats;
|
import gcstats;
|
||||||
|
|
||||||
void addRoot(void *p); // add p to list of roots
|
void addRoot(void *p); // add p to list of roots
|
||||||
|
|
|
@ -8,7 +8,7 @@ module std.math;
|
||||||
|
|
||||||
//debug=math; // uncomment to turn on debugging printf's
|
//debug=math; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
import std.c.stdio;
|
private import std.c.stdio;
|
||||||
|
|
||||||
/* Intrinsics */
|
/* Intrinsics */
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
|
|
||||||
|
module std.moduleinit;
|
||||||
|
|
||||||
//debug = 1;
|
//debug = 1;
|
||||||
|
|
||||||
import object;
|
private
|
||||||
import std.c.stdio;
|
{
|
||||||
import std.c.stdlib;
|
import object;
|
||||||
import std.string;
|
import std.c.stdio;
|
||||||
|
import std.c.stdlib;
|
||||||
|
import std.string;
|
||||||
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{ MIctorstart = 1, // we've started constructing it
|
{ MIctorstart = 1, // we've started constructing it
|
||||||
|
|
|
@ -12,9 +12,14 @@
|
||||||
// from OutBuffer.
|
// from OutBuffer.
|
||||||
// To convert an array of bytes back into raw data, use InBuffer.
|
// To convert an array of bytes back into raw data, use InBuffer.
|
||||||
|
|
||||||
import std.string;
|
module std.outbuffer;
|
||||||
import std.c.stdio;
|
|
||||||
import std.c.stdlib;
|
private
|
||||||
|
{
|
||||||
|
import std.string;
|
||||||
|
import std.c.stdio;
|
||||||
|
import std.c.stdlib;
|
||||||
|
}
|
||||||
|
|
||||||
class OutBuffer
|
class OutBuffer
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.c.stdio;
|
module std.outofmemory;
|
||||||
|
|
||||||
class OutOfMemory : Object
|
class OutOfMemory : Object
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,12 +9,7 @@ module std.path;
|
||||||
|
|
||||||
//debug=path; // uncomment to turn on debugging printf's
|
//debug=path; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
debug(path)
|
private import std.string;
|
||||||
{
|
|
||||||
import std.c.stdio; // for printf()
|
|
||||||
}
|
|
||||||
|
|
||||||
import std.string;
|
|
||||||
|
|
||||||
version(Win32)
|
version(Win32)
|
||||||
{
|
{
|
||||||
|
|
15
std/process.d
Normal file
15
std/process.d
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
// Copyright (c) 2003 by Digital Mars
|
||||||
|
// All Rights Reserved
|
||||||
|
// www.digitalmars.com
|
||||||
|
|
||||||
|
|
||||||
|
module std.process;
|
||||||
|
|
||||||
|
private import std.string;
|
||||||
|
private import std.c.process;
|
||||||
|
|
||||||
|
int system(char[] command)
|
||||||
|
{
|
||||||
|
return std.c.process.system(toStringz(command));
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
// random.d
|
// random.d
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
|
|
||||||
|
module std.random;
|
||||||
|
|
||||||
// Segments of the code in this file Copyright (c) 1997 by Rick Booth
|
// Segments of the code in this file Copyright (c) 1997 by Rick Booth
|
||||||
// From "Inner Loops" by Rick Booth, Addison-Wesley
|
// From "Inner Loops" by Rick Booth, Addison-Wesley
|
||||||
|
@ -13,7 +14,7 @@ version (Win32)
|
||||||
|
|
||||||
version (linux)
|
version (linux)
|
||||||
{
|
{
|
||||||
import std.c.linux.linux;
|
private import std.c.linux.linux;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== Random ========================= */
|
/* ===================== Random ========================= */
|
||||||
|
@ -94,7 +95,6 @@ static this()
|
||||||
rand_seed((uint) s, (uint)(s >> 32));
|
rand_seed((uint) s, (uint)(s >> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
//import std.c.stdio;
|
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,11 +31,14 @@
|
||||||
an error.
|
an error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
module std.regexp;
|
||||||
|
|
||||||
//debug = regexp; // uncomment to turn on debugging printf's
|
//debug = regexp; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
private
|
private
|
||||||
{
|
{
|
||||||
import std.c.stdio;
|
import std.c.stdio;
|
||||||
|
import std.c.stdlib;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.ctype;
|
import std.ctype;
|
||||||
import std.outbuffer;
|
import std.outbuffer;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
module std.stdint;
|
||||||
|
|
||||||
/* Exact sizes */
|
/* Exact sizes */
|
||||||
|
|
||||||
|
|
115
std/string.d
115
std/string.d
|
@ -18,12 +18,14 @@
|
||||||
// The code is not optimized for speed, that will have to wait
|
// The code is not optimized for speed, that will have to wait
|
||||||
// until the design is solidified.
|
// until the design is solidified.
|
||||||
|
|
||||||
|
module std.string;
|
||||||
|
|
||||||
//debug=string; // uncomment to turn on debugging printf's
|
//debug=string; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
debug(string)
|
private import std.c.stdio;
|
||||||
{
|
private import std.c.stdlib;
|
||||||
import std.c.stdio; // for printf()
|
private import std.outbuffer;
|
||||||
}
|
private import std.utf;
|
||||||
|
|
||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +50,7 @@ extern (C)
|
||||||
|
|
||||||
/************** Exceptions ****************/
|
/************** Exceptions ****************/
|
||||||
|
|
||||||
class StringError : Error
|
class StringException : Exception
|
||||||
{
|
{
|
||||||
this(char[] msg)
|
this(char[] msg)
|
||||||
{
|
{
|
||||||
|
@ -1187,7 +1189,7 @@ body
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
debug(string) printf("string.replaceSlice.unittest()\n");
|
debug(string) printf("string.replaceSlice.unittest\n");
|
||||||
|
|
||||||
char[] string = "hello";
|
char[] string = "hello";
|
||||||
char[] slice = string[2 .. 4];
|
char[] slice = string[2 .. 4];
|
||||||
|
@ -1462,7 +1464,7 @@ char[] toString(uint u)
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
debug(string) printf("string.toString.unittest\n");
|
debug(string) printf("string.toString(uint).unittest\n");
|
||||||
|
|
||||||
char[] r;
|
char[] r;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1491,7 +1493,7 @@ char[] toString(char *s)
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
debug(string) printf("string.toString.unittest\n");
|
debug(string) printf("string.toString(char*).unittest\n");
|
||||||
|
|
||||||
char[] r;
|
char[] r;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1506,3 +1508,100 @@ unittest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
char[] format(char[] fmt, ...)
|
||||||
|
{
|
||||||
|
OutBuffer b = new OutBuffer();
|
||||||
|
va_list ap;
|
||||||
|
ap = cast(va_list)&fmt;
|
||||||
|
ap += fmt.size;
|
||||||
|
b.reserve(fmt.length);
|
||||||
|
int fmtlength = fmt.length;
|
||||||
|
char[] s;
|
||||||
|
|
||||||
|
for (int i = 0; i < fmtlength; i++)
|
||||||
|
{
|
||||||
|
char c = fmt[i];
|
||||||
|
if (c != '%')
|
||||||
|
{ b.write(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
if (i == fmtlength)
|
||||||
|
{ b.write(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
c = fmt[i];
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '%':
|
||||||
|
b.write(c);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
{ dchar dc;
|
||||||
|
|
||||||
|
dc = *cast(dchar*)ap;
|
||||||
|
ap += dc.size;
|
||||||
|
if (dc <= 0x7F)
|
||||||
|
b.write(cast(char)dc);
|
||||||
|
else
|
||||||
|
{ char[] s;
|
||||||
|
|
||||||
|
if (!isValidDchar(dc))
|
||||||
|
throw new StringException("invalid dchar value");
|
||||||
|
std.utf.encode(s, dc);
|
||||||
|
b.write(cast(ubyte[])s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
s = *cast(char[]*)ap;
|
||||||
|
ap += s.size;
|
||||||
|
b.write(cast(ubyte[])s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new StringException("invalid format");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cast(char[])b.toBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
debug(string) printf("std.string.format.unittest\n");
|
||||||
|
|
||||||
|
char[] r;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
r = format(null);
|
||||||
|
i = cmp(r, "");
|
||||||
|
assert(i == 0);
|
||||||
|
|
||||||
|
r = format("foo");
|
||||||
|
i = cmp(r, "foo");
|
||||||
|
assert(i == 0);
|
||||||
|
|
||||||
|
r = format("foo%%");
|
||||||
|
i = cmp(r, "foo%");
|
||||||
|
assert(i == 0);
|
||||||
|
|
||||||
|
r = format("foo%c", 'C');
|
||||||
|
i = cmp(r, "fooC");
|
||||||
|
assert(i == 0);
|
||||||
|
|
||||||
|
r = format("%s foo", "bar");
|
||||||
|
i = cmp(r, "bar foo");
|
||||||
|
assert(i == 0);
|
||||||
|
|
||||||
|
r = format("%s foo %s", "bar", "abc");
|
||||||
|
i = cmp(r, "bar foo abc");
|
||||||
|
assert(i == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
import object;
|
module std.switcherr;
|
||||||
import std.c.stdio;
|
|
||||||
|
|
||||||
class SwitchError : Object
|
class SwitchError : Object
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
// Convert Win32 error code to string
|
// Convert Win32 error code to string
|
||||||
|
|
||||||
|
module std.syserror;
|
||||||
|
|
||||||
class SysError
|
class SysError
|
||||||
{
|
{
|
||||||
private import std.c.stdio;
|
private import std.c.stdio;
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
// Information about the target operating system, environment, and CPU
|
// Information about the target operating system, environment, and CPU
|
||||||
|
|
||||||
|
module std.system;
|
||||||
|
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// www.digitalmars.com
|
// www.digitalmars.com
|
||||||
|
|
||||||
|
module std.thread;
|
||||||
|
|
||||||
//debug=thread;
|
//debug=thread;
|
||||||
|
|
||||||
/* ================================ Win32 ================================= */
|
/* ================================ Win32 ================================= */
|
||||||
|
@ -10,7 +12,7 @@
|
||||||
version (Win32)
|
version (Win32)
|
||||||
{
|
{
|
||||||
|
|
||||||
import std.c.windows.windows;
|
private import std.c.windows.windows;
|
||||||
|
|
||||||
extern (Windows) alias uint (*stdfp)(void *);
|
extern (Windows) alias uint (*stdfp)(void *);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// Object[]
|
// Object[]
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ class TypeInfo_AC : TypeInfo
|
||||||
{
|
{
|
||||||
for (uint u = 0; u < s1.length; u++)
|
for (uint u = 0; u < s1.length; u++)
|
||||||
{
|
{
|
||||||
// Do not pass null's to Object.eq()
|
// Do not pass null's to Object.opEquals()
|
||||||
if (s1[u] === s2[u] ||
|
if (s1[u] === s2[u] ||
|
||||||
(s1[u] !== null && s2[u] !== null && s1[u].eq(s2[u])))
|
(s1[u] !== null && s2[u] !== null && s1[u].opEquals(s2[u])))
|
||||||
continue;
|
continue;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class TypeInfo_AC : TypeInfo
|
||||||
{ c = 1;
|
{ c = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c = o1.cmp(o2);
|
c = o1.opCmp(o2);
|
||||||
if (c)
|
if (c)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// char[]
|
// char[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// dchar[]
|
// dchar[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// byte[]
|
// byte[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// int[]
|
// int[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// long[]
|
// long[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// short[]
|
// short[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// ubyte[]
|
// ubyte[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// uint[]
|
// uint[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// ulong[]
|
// ulong[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// ushort[]
|
// ushort[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// wchar[]
|
// wchar[]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
// Object
|
// Object
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class TypeInfo_C : TypeInfo
|
||||||
Object o1 = *(Object*)p1;
|
Object o1 = *(Object*)p1;
|
||||||
Object o2 = *(Object*)p2;
|
Object o2 = *(Object*)p2;
|
||||||
|
|
||||||
return o1 == o2 || (o1 && o1.cmp(o2) == 0);
|
return o1 == o2 || (o1 && o1.opCmp(o2) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int compare(void *p1, void *p2)
|
int compare(void *p1, void *p2)
|
||||||
|
@ -33,7 +33,7 @@ class TypeInfo_C : TypeInfo
|
||||||
{ if (!o2)
|
{ if (!o2)
|
||||||
c = 1;
|
c = 1;
|
||||||
else
|
else
|
||||||
c = o1.cmp(o2);
|
c = o1.opCmp(o2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c = -1;
|
c = -1;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
module std.uri;
|
||||||
|
|
||||||
//debug=uri; // uncomment to turn on debugging printf's
|
//debug=uri; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
/* ====================== URI Functions ================ */
|
/* ====================== URI Functions ================ */
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
// Description of UTF-8 at:
|
// Description of UTF-8 at:
|
||||||
// http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
// http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||||
|
|
||||||
|
module std.utf;
|
||||||
|
|
||||||
//debug=utf; // uncomment to turn on debugging printf's
|
//debug=utf; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
class UtfError : Error
|
class UtfError : Error
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
module std.windows.iunknown;
|
module std.windows.iunknown;
|
||||||
|
|
||||||
import std.c.windows.windows;
|
private import std.c.windows.windows;
|
||||||
|
|
||||||
alias int HRESULT;
|
alias int HRESULT;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Purpose: Win32 Registry manipulation
|
* Purpose: Win32 Registry manipulation
|
||||||
*
|
*
|
||||||
* Created 15th March 2003
|
* Created 15th March 2003
|
||||||
* Updated: 6th November 2003
|
* Updated: 18th October 2003
|
||||||
*
|
*
|
||||||
* Author: Matthew Wilson
|
* Author: Matthew Wilson
|
||||||
*
|
*
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** \file std/windows/registry.d This file contains
|
/** \file D/win32/registry.d This file contains
|
||||||
* the \c std.windows.registry.* classes
|
* the \c D.win32.registry.* classes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ////////////////////////////////////////////////////////////////////////// */
|
/* ////////////////////////////////////////////////////////////////////////// */
|
||||||
|
@ -70,10 +70,6 @@ module std.windows.registry;
|
||||||
* Imports
|
* Imports
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import std.windows.error_codes;
|
|
||||||
import std.windows.exceptions;
|
|
||||||
import std.windows.types;
|
|
||||||
|
|
||||||
//import synsoft.types;
|
//import synsoft.types;
|
||||||
/+ + These are borrowed from synsoft.types, until such time as something similar is in Phobos ++
|
/+ + These are borrowed from synsoft.types, until such time as something similar is in Phobos ++
|
||||||
+/
|
+/
|
||||||
|
@ -111,6 +107,165 @@ public enum Endian
|
||||||
+/
|
+/
|
||||||
|
|
||||||
|
|
||||||
|
//import synsoft.win32.types;
|
||||||
|
/+ + These are borrowed from synsoft.win32.types for the moment, but will not be
|
||||||
|
+ needed once I've convinced Walter to use strong typedefs for things like HKEY +
|
||||||
|
+/
|
||||||
|
public typedef uint Reserved;
|
||||||
|
public typedef void *HKEY;
|
||||||
|
public alias HKEY *PHKEY;
|
||||||
|
public alias char *LPCSTR;
|
||||||
|
public alias int LONG;
|
||||||
|
public alias uint DWORD;
|
||||||
|
public alias DWORD *LPDWORD;
|
||||||
|
public alias void *LPSECURITY_ATTRIBUTES;
|
||||||
|
public alias char *LPSTR;
|
||||||
|
public alias char *LPCSTR;
|
||||||
|
public alias void *LPCVOID;
|
||||||
|
public struct FILETIME
|
||||||
|
{
|
||||||
|
DWORD dwLowDateTime;
|
||||||
|
DWORD dwHighDateTime;
|
||||||
|
};
|
||||||
|
/+
|
||||||
|
+/
|
||||||
|
|
||||||
|
|
||||||
|
//import synsoft.win32.error_codes;
|
||||||
|
/+ +++++++ These are in here for now, but will be in windows.d very soon +++++++
|
||||||
|
+/
|
||||||
|
public const LONG ERROR_SUCCESS = 0;
|
||||||
|
public const LONG ERROR_ACCESS_DENIED = 5;
|
||||||
|
public const LONG ERROR_MORE_DATA = 234;
|
||||||
|
public const LONG ERROR_NO_MORE_ITEMS = 259;
|
||||||
|
/+
|
||||||
|
+/
|
||||||
|
|
||||||
|
|
||||||
|
//import synsoft.win32.exception;
|
||||||
|
/+ +++ This is in here, until the Phobos exception hierarchy is implemented ++++
|
||||||
|
+/
|
||||||
|
class Win32Exception
|
||||||
|
: Exception
|
||||||
|
{
|
||||||
|
/// \name Construction
|
||||||
|
//@{
|
||||||
|
public:
|
||||||
|
/// \brief Creates an instance of the exception
|
||||||
|
///
|
||||||
|
/// \param message The message associated with the exception
|
||||||
|
this(char[] message)
|
||||||
|
{
|
||||||
|
this(message, GetLastError());
|
||||||
|
}
|
||||||
|
/// \brief Creates an instance of the exception, with the given
|
||||||
|
///
|
||||||
|
/// \param message The message associated with the exception
|
||||||
|
/// \param error The Win32 error number associated with the exception
|
||||||
|
this(char[] message, int error)
|
||||||
|
{
|
||||||
|
char sz[24]; // Enough for the three " ()" characters and a 64-bit integer value
|
||||||
|
int cch = wsprintfA(sz, " (%d)", error);
|
||||||
|
|
||||||
|
m_message = message;
|
||||||
|
m_error = error;
|
||||||
|
|
||||||
|
super(message ~ sz[0 .. cch]);
|
||||||
|
}
|
||||||
|
//@}
|
||||||
|
|
||||||
|
/// \name Attributes
|
||||||
|
//@{
|
||||||
|
public:
|
||||||
|
/// Returns the message string associated with the exception
|
||||||
|
char[] Message()
|
||||||
|
{
|
||||||
|
return m_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the Win32 error code associated with the exception
|
||||||
|
int Error()
|
||||||
|
{
|
||||||
|
return m_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Converts the error code into a string
|
||||||
|
///
|
||||||
|
/// \note Not yet implemented
|
||||||
|
char[] LookupError(char[] moduleName)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
/// \name Members
|
||||||
|
//@{
|
||||||
|
private:
|
||||||
|
char[] m_message;
|
||||||
|
int m_error;
|
||||||
|
//@}
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
// (i) Test that we can throw and catch one by its own type
|
||||||
|
try
|
||||||
|
{
|
||||||
|
char[] message = "Test 1";
|
||||||
|
int code = 3;
|
||||||
|
char[] string = "Test 1 (3)";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
throw new Win32Exception(message, code);
|
||||||
|
}
|
||||||
|
catch(Win32Exception x)
|
||||||
|
{
|
||||||
|
assert(x.Error == code);
|
||||||
|
if(message != x.Message)
|
||||||
|
{
|
||||||
|
printf( "UnitTest failure for Win32Exception:\n"
|
||||||
|
" x.message [%d;\"%.*s\"] does not equal [%d;\"%.*s\"]\n"
|
||||||
|
, x.Message.length, x.Message
|
||||||
|
, message.length, message);
|
||||||
|
}
|
||||||
|
assert(message == x.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception /* x */)
|
||||||
|
{
|
||||||
|
int code_flow_should_never_reach_here = 0;
|
||||||
|
assert(code_flow_should_never_reach_here);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (ii) Catch that can throw and be caught by Exception
|
||||||
|
{
|
||||||
|
char[] message = "Test 2";
|
||||||
|
int code = 3;
|
||||||
|
char[] string = "Test 2 (3)";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
throw new Win32Exception(message, code);
|
||||||
|
}
|
||||||
|
catch(Exception x)
|
||||||
|
{
|
||||||
|
if(string != x.toString())
|
||||||
|
{
|
||||||
|
printf( "UnitTest failure for Win32Exception:\n"
|
||||||
|
" x.toString() [%d;\"%.*s\"] does not equal [%d;\"%.*s\"]\n"
|
||||||
|
, x.toString().length, x.toString()
|
||||||
|
, string.length, string);
|
||||||
|
}
|
||||||
|
assert(string == x.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/+
|
||||||
|
+/
|
||||||
|
|
||||||
|
|
||||||
//import synsoft.text.token;
|
//import synsoft.text.token;
|
||||||
/+ ++++++ This is borrowed from synsoft.text.token, until such time as something
|
/+ ++++++ This is borrowed from synsoft.text.token, until such time as something
|
||||||
+ similar is in Phobos ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
+ similar is in Phobos ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
@ -192,12 +347,12 @@ char[][] tokenise(char[] source, char delimiter, boolean bElideBlanks, boolean b
|
||||||
+/
|
+/
|
||||||
|
|
||||||
|
|
||||||
import std.string;
|
private import std.string;
|
||||||
|
|
||||||
/* ////////////////////////////////////////////////////////////////////////// */
|
/* ////////////////////////////////////////////////////////////////////////// */
|
||||||
|
|
||||||
/// \defgroup group_std_windows_reg std.windows.registry
|
/// \defgroup group_D_win32_reg D.win32.registry
|
||||||
/// \ingroup group_std_windows
|
/// \ingroup group_D_win32
|
||||||
/// \brief This library provides Win32 Registry facilities
|
/// \brief This library provides Win32 Registry facilities
|
||||||
|
|
||||||
/* /////////////////////////////////////////////////////////////////////////////
|
/* /////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -893,7 +1048,7 @@ body
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// RegistryException
|
// RegistryException
|
||||||
|
|
||||||
/// Exception class thrown by the std.windows.registry classes
|
/// Exception class thrown by the D.win32.registry classes
|
||||||
///
|
///
|
||||||
/// \ingroup group_D_win32_reg
|
/// \ingroup group_D_win32_reg
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
module std.zlib;
|
module std.zlib;
|
||||||
|
|
||||||
debug=zlib; // uncomment to turn on debugging printf's
|
//debug=zlib; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
private import etc.c.zlib;
|
private import etc.c.zlib;
|
||||||
|
|
||||||
|
|
31
win32.mak
31
win32.mak
|
@ -15,8 +15,8 @@
|
||||||
CP=cp
|
CP=cp
|
||||||
|
|
||||||
CFLAGS=-g -mn -6 -r
|
CFLAGS=-g -mn -6 -r
|
||||||
DFLAGS=-O -release
|
#DFLAGS=-O -release
|
||||||
#DFLAGS=-unittest -g
|
DFLAGS=-unittest -g
|
||||||
|
|
||||||
CC=sc
|
CC=sc
|
||||||
#DMD=\dmd\bin\dmd
|
#DMD=\dmd\bin\dmd
|
||||||
|
@ -51,7 +51,7 @@ unittest.exe : unittest.d phobos.lib
|
||||||
$(DMD) unittest -g
|
$(DMD) unittest -g
|
||||||
sc unittest.obj -g
|
sc unittest.obj -g
|
||||||
|
|
||||||
OBJS= assert.obj deh.obj switch.obj complex.obj gcstats.obj \
|
OBJS= asserterror.obj deh.obj switch.obj complex.obj gcstats.obj \
|
||||||
critical.obj object.obj monitor.obj arraycat.obj invariant.obj \
|
critical.obj object.obj monitor.obj arraycat.obj invariant.obj \
|
||||||
dmain2.obj outofmemory.obj aaA.obj adi.obj file.obj \
|
dmain2.obj outofmemory.obj aaA.obj adi.obj file.obj \
|
||||||
compiler.obj system.obj moduleinit.obj \
|
compiler.obj system.obj moduleinit.obj \
|
||||||
|
@ -60,7 +60,7 @@ OBJS= assert.obj deh.obj switch.obj complex.obj gcstats.obj \
|
||||||
stream.obj switcherr.obj com.obj array.obj gc.obj \
|
stream.obj switcherr.obj com.obj array.obj gc.obj \
|
||||||
qsort.obj math2.obj date.obj dateparse.obj thread.obj obj.obj \
|
qsort.obj math2.obj date.obj dateparse.obj thread.obj obj.obj \
|
||||||
iunknown.obj crc32.obj conv.obj arraycast.obj utf.obj uri.obj \
|
iunknown.obj crc32.obj conv.obj arraycast.obj utf.obj uri.obj \
|
||||||
registry.obj Czlib.obj Dzlib.obj zip.obj \
|
Czlib.obj Dzlib.obj zip.obj process.obj registry.obj \
|
||||||
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
||||||
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
||||||
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
||||||
|
@ -79,9 +79,9 @@ SRCSTD= std\zlib.d std\zip.d std\stdint.d std\conv.d std\utf.d std\uri.d \
|
||||||
std\gc.d std\math.d std\string.d std\path.d std\date.d \
|
std\gc.d std\math.d std\string.d std\path.d std\date.d \
|
||||||
std\ctype.d std\file.d std\compiler.d std\system.d std\moduleinit.d \
|
std\ctype.d std\file.d std\compiler.d std\system.d std\moduleinit.d \
|
||||||
std\outbuffer.d std\math2.d std\thread.d \
|
std\outbuffer.d std\math2.d std\thread.d \
|
||||||
std\assert.d std\dateparse.d std\outofmemory.d \
|
std\asserterror.d std\dateparse.d std\outofmemory.d \
|
||||||
std\intrinsic.d std\array.d std\switcherr.d \
|
std\intrinsic.d std\array.d std\switcherr.d std\syserror.d \
|
||||||
std\regexp.d std\random.d std\stream.d
|
std\regexp.d std\random.d std\stream.d std\process.d
|
||||||
|
|
||||||
SRCSTDC= std\c\process.d std\c\stdlib.d std\c\time.d std\c\stdio.d
|
SRCSTDC= std\c\process.d std\c\stdlib.d std\c\time.d std\c\stdio.d
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ SRCINT= \
|
||||||
internal\dmain2.d internal\cast.d internal\qsort.d internal\deh2.d \
|
internal\dmain2.d internal\cast.d internal\qsort.d internal\deh2.d \
|
||||||
internal\cmath2.d internal\obj.d internal\mars.h
|
internal\cmath2.d internal\obj.d internal\mars.h
|
||||||
|
|
||||||
SRCSTDWIN= std\windows\registry.d std\windows\syserror.d \
|
SRCSTDWIN= std\windows\registry.d \
|
||||||
std\windows\iunknown.d
|
std\windows\iunknown.d
|
||||||
|
|
||||||
SRCSTDCWIN= std\c\windows\windows.d std\c\windows\com.d
|
SRCSTDCWIN= std\c\windows\windows.d std\c\windows\com.d
|
||||||
|
@ -230,8 +230,8 @@ switch.obj : internal\switch.d
|
||||||
array.obj : std\array.d
|
array.obj : std\array.d
|
||||||
$(DMD) -c $(DFLAGS) std\array.d
|
$(DMD) -c $(DFLAGS) std\array.d
|
||||||
|
|
||||||
assert.obj : std\assert.d
|
asserterror.obj : std\asserterror.d
|
||||||
$(DMD) -c $(DFLAGS) std\assert.d
|
$(DMD) -c $(DFLAGS) std\asserterror.d
|
||||||
|
|
||||||
compiler.obj : std\compiler.d
|
compiler.obj : std\compiler.d
|
||||||
$(DMD) -c $(DFLAGS) std\compiler.d
|
$(DMD) -c $(DFLAGS) std\compiler.d
|
||||||
|
@ -275,6 +275,9 @@ outofmemory.obj : std\outofmemory.d
|
||||||
path.obj : std\path.d
|
path.obj : std\path.d
|
||||||
$(DMD) -c $(DFLAGS) std\path.d
|
$(DMD) -c $(DFLAGS) std\path.d
|
||||||
|
|
||||||
|
process.obj : std\process.d
|
||||||
|
$(DMD) -c $(DFLAGS) std\process.d
|
||||||
|
|
||||||
random.obj : std\random.d
|
random.obj : std\random.d
|
||||||
$(DMD) -c $(DFLAGS) std\random.d
|
$(DMD) -c $(DFLAGS) std\random.d
|
||||||
|
|
||||||
|
@ -290,6 +293,9 @@ string.obj : std\string.d
|
||||||
switcherr.obj : std\switcherr.d
|
switcherr.obj : std\switcherr.d
|
||||||
$(DMD) -c $(DFLAGS) std\switcherr.d
|
$(DMD) -c $(DFLAGS) std\switcherr.d
|
||||||
|
|
||||||
|
syserror.obj : std\syserror.d
|
||||||
|
$(DMD) -c $(DFLAGS) std\syserror.d
|
||||||
|
|
||||||
system.obj : std\system.d
|
system.obj : std\system.d
|
||||||
$(DMD) -c $(DFLAGS) std\system.d
|
$(DMD) -c $(DFLAGS) std\system.d
|
||||||
|
|
||||||
|
@ -316,9 +322,6 @@ iunknown.obj : std\windows\iunknown.d
|
||||||
registry.obj : std\windows\registry.d
|
registry.obj : std\windows\registry.d
|
||||||
$(DMD) -c $(DFLAGS) std\windows\registry.d
|
$(DMD) -c $(DFLAGS) std\windows\registry.d
|
||||||
|
|
||||||
syserror.obj : std\windows\syserror.d
|
|
||||||
$(DMD) -c $(DFLAGS) std\windows\syserror.d
|
|
||||||
|
|
||||||
### etc\c
|
### etc\c
|
||||||
|
|
||||||
Czlib.obj : etc\c\zlib.d
|
Czlib.obj : etc\c\zlib.d
|
||||||
|
@ -472,7 +475,7 @@ install:
|
||||||
$(CP) $(SRCINT) \dmd\src\phobos\internal
|
$(CP) $(SRCINT) \dmd\src\phobos\internal
|
||||||
$(CP) $(SRCSTDWIN) \dmd\src\phobos\std\windows
|
$(CP) $(SRCSTDWIN) \dmd\src\phobos\std\windows
|
||||||
$(CP) $(SRCSTDCWIN) \dmd\src\phobos\std\c\windows
|
$(CP) $(SRCSTDCWIN) \dmd\src\phobos\std\c\windows
|
||||||
$(CP) $(SRCSTDCLINUX) \dmd\src\phobos\std\linux
|
$(CP) $(SRCSTDCLINUX) \dmd\src\phobos\std\c\linux
|
||||||
$(CP) $(SRCETC) \dmd\src\phobos\etc\c
|
$(CP) $(SRCETC) \dmd\src\phobos\etc\c
|
||||||
$(CP) $(SRCZLIB) \dmd\src\phobos\etc\c\zlib
|
$(CP) $(SRCZLIB) \dmd\src\phobos\etc\c\zlib
|
||||||
$(CP) $(SRCGC) \dmd\src\phobos\internal\gc
|
$(CP) $(SRCGC) \dmd\src\phobos\internal\gc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue