Skip to content

Commit

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

* remove public operators

* add build command to nim example
  • Loading branch information
thechampagne authored Oct 20, 2023
1 parent dcec4b9 commit 61622a5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,32 @@ main :: proc() {
}
```

#### [Nim](https://nim-lang.org)
> Third party binding: [thechampagne/nimzip](https://github.com/thechampagne/nimzip)
```shell
$ nim c --passL:-lzip main.nim
```

```nim
proc zip_open(zipname: cstring, level: cint, mode: char): pointer {.importc.}
proc zip_close(zip: pointer) {.importc.}
proc zip_entry_open(zip: pointer, entryname: cstring): cint {.importc.}
proc zip_entry_close(zip: pointer): cint {.importc.}
proc zip_entry_write(zip: pointer, buf: pointer, bufsize: csize_t): cint {.importc.}
when isMainModule:
var zip = zip_open("/tmp/nim.zip", 6, 'w')
discard zip_entry_open(zip, "test")
let content: cstring = "test content"
discard zip_entry_write(zip, content, csize_t(len(content)))
discard zip_entry_close(zip)
zip_close(zip)
```

### 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 61622a5

Please sign in to comment.