CloseHandle missing in phobos/std/file.dtrunk/phobos/std/file.d read?
dennis luehring
dl.soluz at gmx.net
Tue Jun 23 04:49:10 PDT 2009
version(Windows) void[] read(in char[] name)
140 {
141 alias TypeTuple!(GENERIC_READ,
142 FILE_SHARE_READ, (SECURITY_ATTRIBUTES*).init,
OPEN_EXISTING,
143 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
144 HANDLE.init)
145 defaults;
146 auto h = useWfuncs
147 ? CreateFileW(std.utf.toUTF16z(name), defaults)
148 : CreateFileA(toMBSz(name), defaults);
149
150 cenforce(h != INVALID_HANDLE_VALUE, name);
151 scope(exit) cenforce(CloseHandle(h), name);
152 const size = GetFileSize(h, null);
153 cenforce(size != INVALID_FILE_SIZE, name);
154 auto buf = GC.malloc(size, GC.BlkAttr.NO_SCAN)[0 .. size];
155 scope(failure) delete buf;
156
157 DWORD numread;
158 cenforce(ReadFile(h,buf.ptr, size, &numread, null) == 1
159 && numread == size, name);
160 return buf[0 .. size];
CloseHandle missing here?
161 }
More information about the Digitalmars-d
mailing list