Skip to content

Commit

Permalink
add D example (#317)
Browse files Browse the repository at this point in the history
* add D example

* add D binding link

* add build command to D example
  • Loading branch information
thechampagne committed Oct 21, 2023
1 parent 4430d0a commit bc4cbda
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,33 @@ when isMainModule:
zip_close(zip)
```

#### [D](https://dlang.org)
> Third party binding: [thechampagne/zip-d](https://github.com/thechampagne/zip-d)
```shell
$ dmd -L-lzip main.d
```

```d
extern(C) void* zip_open(const(char)* zipname, int level, char mode);
extern(C) void zip_close(void* zip);
extern(C) int zip_entry_open(void* zip, const(char)* entryname);
extern(C) int zip_entry_close(void* zip);
extern(C) int zip_entry_write(void* zip, const(void)* buf, size_t bufsize);
void main()
{
void* zip = zip_open("/tmp/d.zip", 6, 'w');
scope(exit) zip_close(zip);
zip_entry_open(zip, "test");
scope(exit) zip_entry_close(zip);
string content = "test content";
zip_entry_write(zip, content.ptr, content.length);
}
```

### Check out more cool projects which use this library

* [Filament](https://github.com/google/filament): Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, and WebGL. It is designed to be as small as possible and as efficient as possible on Android.
Expand Down

0 comments on commit bc4cbda

Please sign in to comment.