Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Make changes to readme, add stuff for making this a proper Godot plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
jellehermsen committed Jan 2, 2019
1 parent b84f263 commit 9862d4e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,45 @@ for f in gdunzip.files:
print('Uncompressed size: ' + str(f['uncompressed_size']))
```

Class documentation
-------------------

### Member functions
| Returns | Function name |
| -------------------------------- | ---------------------- |
| bool | load(String path) |
| PoolByteArray | uncompress(String file_name)|
| PoolByteArray | get_compressed(String file_name) |

### Member function description

- bool **load**(String path)

Tries to load a zip file with a given path. Returns false if it failed
loading the zip, or true if it was successfull.

- PoolByteArray **uncompress**(String file_name)

Try to uncompress the given file in the loaded zip. The file_name can include
directories. This function returns *false* if the file can't be found, or if
there's an error during uncompression.

- PoolByteArray **get_compressed**(String file_name)

Returns the compressed data for a given file name (or false if the file can't
be found). Depending on the file compression it can be either uncompressed or a
raw deflate stream. This function returns *false* if the file can't be found.

### files attribute
After you have loaded a file, the gdunzip instance will have a pre-filled
"files" attribute. This is simply an dictionary containing the meta data for
the files that reside in the zip. The dictionary is a mapping from file name
(including directory) to another directory with the following keys:

- file_name: the file name
- compression_method: -1 if uncompressed or File.COMPRESSION_DEFLATE
- file_header_offset: the exact byte location of this file's compressed data
inside the zip file
- compressed_size: the compressed file size in bytes
- uncompressed_size: the uncompressed file size in bytes
File renamed without changes.
6 changes: 6 additions & 0 deletions addons/gdunzip/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[plugin]
name="gdunzip"
description="A script for browsing and uncompressing ZIP files."
author="Jelle Hermsen"
version="1.0.0"
script="gdunzip.gd"
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func _red_text(text):
func _test(test_name, zip_file, files):
print('[' + test_name + ']')

var gdunzip = load('res://src/gdunzip.gd').new()
var gdunzip = load('res://addons/gdunzip/gdunzip.gd').new()
var loaded = gdunzip.load(zip_file)

if !loaded:
Expand Down

0 comments on commit 9862d4e

Please sign in to comment.