Re: Modern COM Programming in D
On Tuesday, 3 April 2012 at 14:10:32 UTC, Jesse Phillips wrote: On Tuesday, 3 April 2012 at 07:49:28 UTC, Sam Hu wrote: Sorry the link http://dpxml-lio/d is unreachable from my side (maybe someone blocked it :P).Could you please provide an alternative place for download? Appreciated. Regards, Sam Most of his code isn't available as it was kind of under Microsoft. However I revived Juno for D2 awhile ago (still need to play with it myself). Juno provides some nice tools and API. https://github.com/JesseKPhillips/Juno-Windows-Class-Library http://dsource.org/projects/juno Thanks for the reply.Yes,Juno is great,I use it since D1. Regards, Sam
code to get LCN from filename
I hacked up one of the file.d functions to create a function that returns the first Logical Cluster Number for a regular file. I've tested it on the 2GB layout that has been defragged with the myDefrag sortByName() operation, and it works as expected. Values of 0 mean the file was small enough to fit in the MFT. The LCN numbers would be a good thing to sort by before doing accesses on entries coming from any large directory operations ... for example zip, copy, delete of directories. enum { FILE_DEVICE_FILE_SYSTEM = 9, METHOD_NEITHER = 3, FILE_ANY_ACCESS = 0 } uint CTL_CODE(uint t, uint f, uint m, uint a) { return (t << 16) | (a << 14) | (f << 2) | m; } const FSCTL_GET_RETRIEVAL_POINTERS = CTL_CODE(FILE_DEVICE_FILE_SYSTEM,28,METHOD_NEITHER,FILE_ANY_ACCESS); /* extern (Windows) int DeviceIoControl(void *, uint, void *, uint, void *, uint, uint *, _OVERLAPPED *); from WinIoCtl.h in SDK #define FSCTL_GET_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER */ struct RETRIEVAL_POINTERS_BUFFER{ } ulong getStartLCN (in char[] name) { int[] buffer = [ 0 ]; version(Windows) { alias TypeTuple!(GENERIC_READ, FILE_SHARE_READ, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, HANDLE.init) defaults; auto h = useWfuncs ? CreateFileW(std.utf.toUTF16z(name), defaults) : CreateFileA(toMBSz(name), defaults); cenforce(h != INVALID_HANDLE_VALUE, name); scope(exit) cenforce(CloseHandle(h), name); alias long LARGE_INTEGER ; struct STARTING_VCN_INPUT_BUFFER { LARGE_INTEGER StartingVcn; } STARTING_VCN_INPUT_BUFFER inputVcn; inputVcn.StartingVcn = 0; struct RPExtents{ LARGE_INTEGER NextVcn; LARGE_INTEGER Lcn; } struct RETRIEVAL_POINTERS_BUFFER { DWORD ExtentCount; LARGE_INTEGER StartingVcn; RPExtents rpExtents[1]; } RETRIEVAL_POINTERS_BUFFER rpBuf; DWORD numBytes; //expect only a partial return of one rpExtent DeviceIoControl( h, FSCTL_GET_RETRIEVAL_POINTERS, cast(void*)&inputVcn, inputVcn.sizeof, cast(void*)&rpBuf, rpBuf.sizeof, &numBytes, null ); return cast(ulong)rpBuf.rpExtents[0].Lcn; } else version(Posix) return 0; // not implemented }
Re: I'll be in Seattle at Lang.NEXT
On 4/8/12 11:31 AM, bearophile wrote: Andrei Alexandrescu: Slides are online: http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely-Successful-Features-of-D Putting the slides online before the talk is a very good idea, thank you. Page 31: the title of this slide is "D array = pointer + length", but the image shows two pointers inside the array struct/fat pointer. I mention during the talk that the concept is the same regardless of that representation detail. Andrei
Re: I'll be in Seattle at Lang.NEXT
Andrei Alexandrescu: > Slides are online: > http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely-Successful-Features-of-D Putting the slides online before the talk is a very good idea, thank you. Page 31: the title of this slide is "D array = pointer + length", but the image shows two pointers inside the array struct/fat pointer. Walter has said several times his desire to replace the pointer + length with two pointers. Are those desires going to produce a change? And even if this is a bit OT: why aren't D array fat references composed by 3 fields: pointer + length + capacity? I think Go slices are like this. Page 34, "Convenient": I don't know how well DMD will optimize this code, but it's one of the simplest to read array-twiddling palindrome functions I've seen. But probably I write: !a.empty Instead of: a.length Page 36, "Palindrome generalized": unfortunately D doesn't map syntaxes like a[1..$-1] to range functions :-) Page 51: An horizontal line needs to be at 1.0 too. But I prefer a graph that shows run-time seconds. Very nice slides pack. Bye, bearophile
Re: DMagick image processing with D.
Thanks for DMagick... works great, except toBlob(). When I try the following: Image example = new Image(Geometry(100, 100), new ColorRGB(0, 255, 0)); example.toBlob(); I get an access violation. Do I anything wrong or is it a bug? (I'm using Imagick 6.7.6, DMD64 and CentOS)
Re: unzip parallel, 3x faster than 7zip
On Sunday, 8 April 2012 at 13:55:21 UTC, Marco Leise wrote: Maybe the kernel caches writes, but synchronizes deletes? (So the seek times become apparent there, and not in the writes) Also check the file creation flags, maybe you can hint Windows to the final file size and they wont be fragmented? My understanding is that a delete operation occurs after all the file handles associated with a file are closed, assuming there other handles were opened with file_share_delete. I believe otherwise you get an error from the attempt to delete. I'm doing some experiments with myFrag sortByName() and it indicates to me that there will be huge improvments in delete efficiency available on a hard drive if you can figure out some way to get the os to arrange the files and directories in LCNs in that byName order. Below are the delete time from win7 rmdir on the same 2GB folder with and without defrag using myFrag sortByName(). This is win7 rmdir following myFrag sortByName() defrag ... less than 7 seconds G:\>cmd /v:on /c "echo !TIME! & rmdir /q /s tz & echo !TIME!" 9:06:33.79 9:06:40.47 This is the same rmdir without defrag of the folder. 2 minutes 14 secs. G:\>cmd /v:on /c "echo !TIME! & rmdir /q /s tz & echo !TIME!" 14:34:09.06 14:36:23.36 This is all on win7 ntfs, and I have no idea if similar gains are available for linux. So, yes, whatever tricks you can play with the win api in order to get it to organize the unzipped archive into this particular order is going to make huge improvements in the speed of delete.
Re: unzip parallel, 3x faster than 7zip
Am Sat, 07 Apr 2012 21:45:04 +0200 schrieb "Jay Norwood" : > So ... it looks like the defrag helps, as the 109 sec values are > at the low end of the range I've seen previously. Still it is > totally surprising to me that deleting files should take longer > than creating the same files. Maybe the kernel caches writes, but synchronizes deletes? (So the seek times become apparent there, and not in the writes) Also check the file creation flags, maybe you can hint Windows to the final file size and they wont be fragmented?
VBScript helper
MS Windows is shipped with Windows Script Host (WSH), for every single malware developer to be able to do everything once he finally forced you to double-click on a small text file. Now WSH works for D developer too by providing easy (but not very fast) access to system information (yes, and COM objects). See example in docs. For now it only reads objects from VBScript. Writing data back and calling functions on VBScript objects can be added if someone really needs it (just contact me). Sources: https://bitbucket.org/denis_sh/misc/src/tip/vbscripthelper.d Docs: http://deoma-cmd.ru/d/docs/misc/vbscripthelper.html -- Денис В. Шеломовский Denis V. Shelomovskij