Skip to content

Commit

Permalink
module: zip: Update for recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswestman committed Mar 8, 2022
1 parent ca1925b commit c35d168
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 83 deletions.
53 changes: 20 additions & 33 deletions modules/zip/doc_classes/ZIPPacker.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ZIPPacker" inherits="Reference" version="4.0">
<class name="ZIPPacker" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Class for creating zip archives
</brief_description>
Expand All @@ -17,56 +17,43 @@
<tutorials>
</tutorials>
<methods>
<method name="close">
<return type="int" enum="Error" />
<description>
Closes the zip file and flushes the data to the disk.
</description>
</method>
<method name="close_file">
<return type="int" enum="Error" />
<description>
Closes the file that was opened with [method start_file].
</description>
</method>
<method name="open">
<return type="int" enum="Error">
</return>
<argument index="0" name="path" type="String">
</argument>
<argument index="1" name="append" type="int" enum="ZIPPacker.ZipAppend" default="0">
</argument>
<return type="int" enum="Error" />
<argument index="0" name="path" type="String" />
<argument index="1" name="append" type="int" enum="ZIPPacker.ZipAppend" default="0" />
<description>
Opens a zip file to start writing. What happens if the file already exists is determined by [code]append[/code].
</description>
</method>
<method name="start_file">
<return type="int" enum="Error">
</return>
<argument index="0" name="path" type="String">
</argument>
<return type="int" enum="Error" />
<argument index="0" name="path" type="String" />
<description>
Starts a new file in the zip archive. Subsequent calls to [method write_file] will write to this file.
If the file at the given path already exists, a duplicate entry will be created.
</description>
</method>
<method name="write_file">
<return type="int" enum="Error">
</return>
<argument index="0" name="data" type="PackedByteArray">
</argument>
<return type="int" enum="Error" />
<argument index="0" name="data" type="PackedByteArray" />
<description>
Writes data to a file in the archive. Which file is written to is determined by the latest call to [method start_file].
If the file has already been written to, the data will be appended.
</description>
</method>
<method name="close_file">
<return type="int" enum="Error">
</return>
<description>
Closes the file that was opened with [method start_file].
</description>
</method>
<method name="close">
<return type="int" enum="Error">
</return>
<description>
Closes the zip file and flushes the data to the disk.
</description>
</method>
</methods>
<members>
</members>
<signals>
</signals>
<constants>
<constant name="APPEND_CREATE" value="0" enum="ZipAppend">
The file will be created if it does not exist, or overwritten if it does exist.
Expand Down
43 changes: 15 additions & 28 deletions modules/zip/doc_classes/ZIPReader.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ZIPReader" inherits="Reference" version="4.0">
<class name="ZIPReader" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Class for reading zip archives
</brief_description>
Expand All @@ -15,47 +15,34 @@
<tutorials>
</tutorials>
<methods>
<method name="open">
<return type="int" enum="Error">
</return>
<argument index="0" name="path" type="String">
</argument>
<method name="close">
<return type="int" enum="Error" />
<description>
Opens a zip file for reading. If a file was already open, that file will be closed.
Closes the file. Subsequent operations other than [method open] will fail after this is called.
</description>
</method>
<method name="get_files">
<return type="PackedStringArray">
</return>
<return type="PackedStringArray" />
<description>
Returns the list of file paths in the archive. All paths are relative to the root of the archive.
For example, if you have an archive containg a folder, "foo", which contains a file, "bar.txt", the list will contain one item: "foo/bar.txt".
</description>
</method>
<method name="read_file">
<return type="PackedByteArray">
</return>
<argument index="0" name="path" type="String">
</argument>
<argument index="1" name="case_sensitive" type="bool" default="true">
</argument>
<method name="open">
<return type="int" enum="Error" />
<argument index="0" name="path" type="String" />
<description>
Returns the contents of a file in the archive as a [PackedByteArray]. If you need the contents as a string, use [method PackedByteArray.get_string_from_utf8].
If there is a problem reading the file (such as the file doesn't exist), an empty PackedByteArray will be returned and an error will be logged to the console.
Opens a zip file for reading. If a file was already open, that file will be closed.
</description>
</method>
<method name="close">
<return type="int" enum="Error">
</return>
<method name="read_file">
<return type="PackedByteArray" />
<argument index="0" name="path" type="String" />
<argument index="1" name="case_sensitive" type="bool" default="true" />
<description>
Closes the file. Subsequent operations other than [method open] will fail after this is called.
Returns the contents of a file in the archive as a [PackedByteArray]. If you need the contents as a string, use [method PackedByteArray.get_string_from_utf8].
If there is a problem reading the file (such as the file doesn't exist), an empty PackedByteArray will be returned and an error will be logged to the console.
</description>
</method>
</methods>
<members>
</members>
<signals>
</signals>
<constants>
</constants>
</class>
4 changes: 2 additions & 2 deletions modules/zip/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand Down
4 changes: 2 additions & 2 deletions modules/zip/register_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand Down
8 changes: 4 additions & 4 deletions modules/zip/zip_packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand Down Expand Up @@ -58,9 +58,9 @@ Error ZIPPacker::start_file(String path) {

zipfi.tmz_date.tm_hour = time.hour;
zipfi.tmz_date.tm_mday = date.day;
zipfi.tmz_date.tm_min = time.min;
zipfi.tmz_date.tm_min = time.minute;
zipfi.tmz_date.tm_mon = date.month - 1;
zipfi.tmz_date.tm_sec = time.sec;
zipfi.tmz_date.tm_sec = time.second;
zipfi.tmz_date.tm_year = date.year;
zipfi.dosDate = 0;
zipfi.external_fa = 0;
Expand Down
12 changes: 6 additions & 6 deletions modules/zip/zip_packer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand All @@ -31,14 +31,14 @@
#ifndef ZIP_PACKER_H
#define ZIP_PACKER_H

#include "core/object/reference.h"
#include "core/object/ref_counted.h"

#include "core/os/file_access.h"
#include "core/io/file_access.h"
#include "core/os/os.h"
#include "thirdparty/minizip/zip.h"

class ZIPPacker : public Reference {
GDCLASS(ZIPPacker, Reference);
class ZIPPacker : public RefCounted {
GDCLASS(ZIPPacker, RefCounted);

FileAccess *f;
zipFile zf;
Expand Down
4 changes: 2 additions & 2 deletions modules/zip/zip_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand Down
12 changes: 6 additions & 6 deletions modules/zip/zip_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand All @@ -31,14 +31,14 @@
#ifndef ZIP_READER_H
#define ZIP_READER_H

#include "core/object/reference.h"
#include "core/object/ref_counted.h"

#include "core/os/file_access.h"
#include "core/io/file_access.h"
#include "core/os/os.h"
#include "thirdparty/minizip/unzip.h"

class ZIPReader : public Reference {
GDCLASS(ZIPReader, Reference)
class ZIPReader : public RefCounted {
GDCLASS(ZIPReader, RefCounted)

FileAccess *f;
unzFile uzf;
Expand Down

0 comments on commit c35d168

Please sign in to comment.