5

D, being the lesser known language of the bunch, has very little going for it in the way of libraries. I am trying to download a file, and the way I can see to do that with DMD 2 and phobos is with etc.c.curl, but... Curl is very difficult to use. And since I can not find a good example anywhere. How do you download a file in the simplest way possible using etc.c.curl?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
alexmherrmann
  • 1,055
  • 2
  • 9
  • 17

1 Answers1

6

I don't know very much about the etc.c.curl API, which is just a binding to the C Curl library. A much easier to use D-style wrapper is currently in formal review, though, and will probably find its way into one of the next two Phobos/DMD releases. If you want to try it out in the mean time (with the understanding that there may be breaking changes to it prompted by the review process), see:

https://github.com/jcd/phobos/blob/curl-wrapper/etc/curl.d (Code)

http://freeze.steamwinter.com/D/web/phobos/etc_curl.html (Documentation)

If you don't want to use a wrapper that's this bleeding edge, you can also look at the code to it to figure out how to accomplish what you want to accomplish using the etc.c.curl C binding.

dsimcha
  • 67,514
  • 53
  • 213
  • 334
  • Is there one in the official Phobos repo yet? – alexmherrmann Aug 21 '11 at 20:17
  • Thank you, I asked a similar question, and the same two links were brought up! – alexmherrmann Aug 21 '11 at 20:21
  • 1
    @alexhairyman: No, the whole point of the review process is to improve the module and determine whether it gets into Phobos. BTW, the library situation in D should improve rapidly. Since D2 became stable, there has been tons of community effort towards writing libraries. The review process for each Phobos module usually takes 3-4 weeks and there's currently a backlog of modules waiting to be reviewed. These include the Curl wrapper, logging, runtime reflection, an improved std.process, decimal arithmetic, a CSV parser, memory allocators and parallel algorithms. – dsimcha Aug 21 '11 at 20:28
  • how can one contribute? Would I need to fork it on github and then how would I submit it? – alexmherrmann Aug 21 '11 at 21:13
  • 1
    @alexhairyman: For improvements to existing modules, you fork Phobos on Github, make your modifications and then submit a pull request. The pull request is reviewed by the core Phobos devs and merged if accepted. The review process takes a few days and multiple reviews happen in parallel. For new modules or major rewrites of existing modules, you post both the code and the documentation somewhere, then make a proposal on the digitalmars.d newsgroup. There will then be a public review (a few weeks) and a vote. – dsimcha Aug 21 '11 at 22:16