Skip to content

Commit

Permalink
Merge pull request #49 from Gottox/cleanup/readme-example
Browse files Browse the repository at this point in the history
README.md: add explanation to examples.
  • Loading branch information
Gottox authored Aug 21, 2023
2 parents 679de9b + d3cefcc commit 5ef4f38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
23 changes: 5 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ provides zero-copy interfaces to the squashfs archives.

## Example

This is a simple example that a) prints the content of a file and b) lists the
content of a directory.

```c
struct SqshArchive *archive =
sqsh_archive_open("/path/to/archive.squashfs", NULL, NULL);
Expand All @@ -25,8 +28,7 @@ const size_t size = sqsh_easy_file_size(archive, "/path/to/file", NULL);
fwrite(contents, 1, size, stdout);
free(contents);

char **files =
sqsh_easy_directory_list(archive, "/path/to/directory", NULL);
char **files = sqsh_easy_directory_list(archive, "/path/to/dir", NULL);
assert(files != NULL);
for (int i = 0; files[i] != NULL; i++) {
printf("%s\n", files[i]);
Expand All @@ -36,22 +38,7 @@ free(files);
sqsh_archive_close(archive);
```
## Roadmap to 1.0
* [x] directory listing
* [x] file content reading
* [x] inode metadata
* [x] path traversal
* [x] xattr support
* [x] symlink resolution for path traversal
* [x] LRU cache for metadata
* [x] LRU cache for file content
* [x] thread safety
* [x] fuse file system
* [x] OpenBSD support
* [x] FreeBSD support
* [ ] refine the high-level API
* [x] refine the low-level API
Find further examples in the [examples](examples) directory.
## Building
Expand Down
3 changes: 1 addition & 2 deletions examples/readme_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ main(int argc, char *argv[]) {
fwrite(contents, 1, size, stdout);
free(contents);

char **files =
sqsh_easy_directory_list(archive, "/path/to/directory", NULL);
char **files = sqsh_easy_directory_list(archive, "/path/to/dir", NULL);
assert(files != NULL);
for (int i = 0; files[i] != NULL; i++) {
printf("%s\n", files[i]);
Expand Down

0 comments on commit 5ef4f38

Please sign in to comment.