-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4845 from pblottiere/zip
[FEATURE] New zip format
- Loading branch information
Showing
19 changed files
with
1,139 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ matrix: | |
- poppler-utils | ||
- xvfb | ||
- clang-3.8 | ||
- libzip-dev | ||
|
||
|
||
- os: linux | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# CMake module to search for libzip | ||
# | ||
# Once done this will define | ||
# | ||
# LIBZIP_FOUND - system has the zip library | ||
# LIBZIP_INCLUDE_DIR - the zip include directory | ||
# LIBZIP_LIBRARY - Link this to use the zip library | ||
# | ||
# Copyright (c) 2017, Paul Blottiere, <paul.blottiere@oslandia.com> | ||
# | ||
# Redistribution and use is allowed according to the terms of the BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
|
||
FIND_PATH(LIBZIP_INCLUDE_DIR | ||
zip.h | ||
PATHS | ||
/usr/local/include | ||
/usr/include | ||
"$ENV{LIB_DIR}/include" | ||
"$ENV{INCLUDE}" | ||
) | ||
|
||
FIND_LIBRARY(LIBZIP_LIBRARY | ||
NAMES zip | ||
PATHS | ||
/usr/local/lib | ||
/usr/lib | ||
"$ENV{LIB_DIR}/lib" | ||
"$ENV{LIB}" | ||
) | ||
|
||
IF (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR) | ||
SET(LIBZIP_FOUND TRUE) | ||
ENDIF (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR) | ||
|
||
IF (LIBZIP_FOUND) | ||
MESSAGE(STATUS "Found libzip: ${LIBZIP_LIBRARY}") | ||
ELSE (LIPZIP_FOUND) | ||
MESSAGE(FATAL_ERROR "Could not find libzip") | ||
ENDIF (LIBZIP_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsarchive.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsArchive | ||
{ | ||
%Docstring | ||
Class allowing to manage the zip/unzip actions | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsarchive.h" | ||
%End | ||
public: | ||
|
||
QgsArchive(); | ||
%Docstring | ||
Constructor | ||
%End | ||
|
||
QgsArchive( const QgsArchive &other ); | ||
%Docstring | ||
Copy constructor | ||
%End | ||
|
||
|
||
virtual ~QgsArchive(); | ||
%Docstring | ||
Destructor | ||
%End | ||
|
||
bool zip( const QString &zipFilename ); | ||
%Docstring | ||
Zip the content of this archive | ||
\param zipFilename The name of the zip to generate | ||
:return: false if something goes wrong, true otherwise | ||
:rtype: bool | ||
%End | ||
|
||
virtual bool unzip( const QString &zipFilename ); | ||
%Docstring | ||
Clear the current content of this archive and unzip. Files are unzipped | ||
in the temporary directory. | ||
\param zipFilename The zip file to unzip | ||
:return: true if unzip action is a success, false otherwise | ||
:rtype: bool | ||
%End | ||
|
||
void clear(); | ||
%Docstring | ||
Clear the current content of this archive and create a new temporary | ||
directory. | ||
%End | ||
|
||
void addFile( const QString &filename ); | ||
%Docstring | ||
Add a new file to this archive. During a zip action, this file will be | ||
part of the resulting zipped file. | ||
\param filename A file to add when zipping this archive | ||
%End | ||
|
||
bool removeFile( const QString &filename ); | ||
%Docstring | ||
Remove a file from this archive and from the filesystem. | ||
\param filename The path of the file to remove | ||
:return: true if the file has been removed from the filesystem, false otherwise | ||
:rtype: bool | ||
%End | ||
|
||
QStringList files() const; | ||
%Docstring | ||
Returns the list of files within this archive | ||
:rtype: list of str | ||
%End | ||
|
||
QString dir() const; | ||
%Docstring | ||
Returns the current temporary directory. | ||
:rtype: str | ||
%End | ||
|
||
}; | ||
|
||
class QgsProjectArchive : QgsArchive | ||
{ | ||
%Docstring | ||
Class allowing to manage the zip/unzip actions on project file | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsarchive.h" | ||
%End | ||
public: | ||
|
||
virtual bool unzip( const QString &zipFilename ); | ||
|
||
%Docstring | ||
Clear the current content of this archive and unzip. If a project file | ||
is found in the content, then this archive may be considered as a valid | ||
one. Files are unzipped in the temporary directory. | ||
\param zipFilename The zip file to unzip | ||
:return: true if a project file has been found, false otherwise | ||
:rtype: bool | ||
%End | ||
|
||
QString projectFile() const; | ||
%Docstring | ||
Returns the current .qgs project file or an empty string if there's none | ||
:rtype: str | ||
%End | ||
|
||
bool clearProjectFile(); | ||
%Docstring | ||
Remove the current .qgs project file from the temporary directory. | ||
:return: true if the file is well removed, false otherwise | ||
:rtype: bool | ||
%End | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsarchive.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsziputils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
%ModuleHeaderCode | ||
#include "qgsziputils.h" | ||
%End | ||
|
||
namespace QgsZipUtils | ||
{ | ||
|
||
bool isZipFile( const QString &filename ); | ||
%Docstring | ||
Returns true if the file name is a zipped file ( i.e with a '.qgz' | ||
extension, false otherwise. | ||
\param filename The name of the file | ||
:return: true if the file is zipped, false otherwise | ||
:rtype: bool | ||
%End | ||
|
||
bool unzip( const QString &zip, const QString &dir, QStringList &files /Out/ ); | ||
%Docstring | ||
Unzip a zip file in an output directory. An error is returned if the zip | ||
filename does not exist, the output directory does not exist or is | ||
not writable. | ||
\param zip The zip filename | ||
\param dir The output directory | ||
\param files The absolute path of unzipped files | ||
.. versionadded:: 3.0 | ||
:rtype: bool | ||
%End | ||
|
||
bool zip( const QString &zip, const QStringList &files ); | ||
%Docstring | ||
Zip the list of files in the zip file. If the zip file already exists or is | ||
empty, an error is returned. If an input file does not exist, an error is | ||
also returned. | ||
\param zip The zip filename | ||
\param files The absolute path to files to embed within the zip | ||
.. versionadded:: 3.0 | ||
:rtype: bool | ||
%End | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsziputils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.