You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/02/11 19:56:16 UTC

[1/3] incubator-corinthia git commit:

work
X-Virus-Checked: Checked by ClamAV on apache.org

Repository: incubator-corinthia
Updated Branches:
  refs/heads/experimentzip [created] 768c5aad4



work


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/74118675
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/74118675
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/74118675

Branch: refs/heads/experimentzip
Commit: 74118675f9cd92a3907918c2f74d1dcd049104d0
Parents: 9e8e44c
Author: jani <ja...@apache.org>
Authored: Sun Feb 1 09:57:17 2015 +0100
Committer: jani <ja...@apache.org>
Committed: Sun Feb 1 09:57:17 2015 +0100

----------------------------------------------------------------------
 DocFormats/platform/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/74118675/DocFormats/platform/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/platform/CMakeLists.txt b/DocFormats/platform/CMakeLists.txt
index f3ba68b..cd7c28f 100644
--- a/DocFormats/platform/CMakeLists.txt
+++ b/DocFormats/platform/CMakeLists.txt
@@ -93,6 +93,7 @@ set(GroupSrc
     src/Linux.c
     src/Unix.c
     src/Win32.c
+    src/ZipWrapper.c
     src/Wrapper.c)
 
 set(GroupTests


Re: [3/3] incubator-corinthia git commit: added wrapper for zip.

Posted by jan i <ja...@apache.org>.
On 12 February 2015 at 22:29, Dave Fisher <da...@comcast.net> wrote:

> HI Jani -
>
> Just part of the Incubator process. If it is on the list then I am fine
> with what you outlined. Just trying to keep active as a Mentor.
>
Sorry if I sounded negative....you are doing exactly what a mentor should
do !


>
> I am more making the point that new files added by the team should be done
> in the proper way.
>
I totally agree, and took the consequence and updated all the files I have
been refactoring.

I am also negotiating with Peter to change all files on behalf of
UXproductivity, since he is busy with $DAYJOB at the moment. As long as he
states on the jira issue, that he iis happy with me doing the work, there
cannot be any real problems (this have been done in a number of podlings).

rgds
jan i.


>
> Thanks,
> Dave
>
> On Feb 12, 2015, at 12:57 PM, jan i wrote:
>
> > On 12 February 2015 at 21:20, Dave Fisher <da...@comcast.net> wrote:
> >
> >> JanI -
> >>
> >> A question. Why is there a copyright in this file?
> >>
> >> Did this file come from UX Productivity as part of the initial grant or
> >> did you write it to contribute?
> >>
> >> Depending on the answer action should be taken to comply with
> >> http://www.apache.org/legal/src-headers.html
> >
> >
> > I wrote it to contrbute, but actually the file dates back from before we
> > entered incubator. I have a small set of files, that I worked on earlier
> > which was not in trunk....
> >
> > Peter is working on a scripts that goes through all files to replace the
> > license with a new one, my reasoning was to keep everything identical
> until
> > then. We have a jira for it.
> >
> > If this procedure disturbs you then I will change that file specifically,
> > and Peter might then need to make the script a bit more complex (check if
> > header is already changed).
> >
> > Just to be precise you have caught 1 of approx 10 files that have been
> > added after we entered incubator (I have not counted, but it is my
> feeling).
> >
> > No doubt we need to get all headers corrected. I had made the change
> > already, had we not agreed that peter needs to do it.
> >
> > rgds
> > jan I.
> >
> >
> >>
> >> Regards,
> >> Dave
> >>
> >> On Feb 11, 2015, at 10:56 AM, jani@apache.org wrote:
> >>
> >>> added wrapper for zip.
> >>>
> >>>
> >>> Project:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
> >>> Commit:
> >>
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/768c5aad
> >>> Tree:
> >>
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/768c5aad
> >>> Diff:
> >>
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/768c5aad
> >>>
> >>> Branch: refs/heads/experimentzip
> >>> Commit: 768c5aad43a31a2e30c0cda101ffa12cf276fa23
> >>> Parents: 0fbd721
> >>> Author: jani <ja...@apache.org>
> >>> Authored: Wed Feb 11 19:55:38 2015 +0100
> >>> Committer: jani <ja...@apache.org>
> >>> Committed: Wed Feb 11 19:55:38 2015 +0100
> >>>
> >>> ----------------------------------------------------------------------
> >>> DocFormats/platform/src/ZipWrapper.c | 146
> ++++++++++++++++++++++++++++++
> >>> 1 file changed, 146 insertions(+)
> >>> ----------------------------------------------------------------------
> >>>
> >>>
> >>>
> >>
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/768c5aad/DocFormats/platform/src/ZipWrapper.c
> >>> ----------------------------------------------------------------------
> >>> diff --git a/DocFormats/platform/src/ZipWrapper.c
> >> b/DocFormats/platform/src/ZipWrapper.c
> >>> new file mode 100644
> >>> index 0000000..14ed093
> >>> --- /dev/null
> >>> +++ b/DocFormats/platform/src/ZipWrapper.c
> >>> @@ -0,0 +1,146 @@
> >>> +// Copyright 2012-2014 UX Productivity Pty Ltd
> >>> +//
> >>> +// Licensed under the Apache License, Version 2.0 (the "License");
> >>> +// you may not use this file except in compliance with the License.
> >>> +// You may obtain a copy of the License at
> >>> +//
> >>> +// http://www.apache.org/licenses/LICENSE-2.0
> >>> +//
> >>> +// Unless required by applicable law or agreed to in writing, software
> >>> +// distributed under the License is distributed on an "AS IS" BASIS,
> >>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> >> implied.
> >>> +// See the License for the specific language governing permissions and
> >>> +// limitations under the License.
> >>> +#include <string.h>
> >>> +#include <stdlib.h>
> >>> +#include "DFPlatform.h"
> >>> +#include "unzip.h"
> >>> +#include "zip.h"
> >>> +
> >>> +
> >>> +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
> >>> +    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
> >>> +
> >>> +    // no more memory
> >>> +    if (!zipHandle)
> >>> +        return NULL;
> >>> +
> >>> +    // Open file
> >>> +    zipHandle->zipFirst = 1;
> >>> +    zipHandle->zipFlag = doUnzip;
> >>> +    if (doUnzip)
> >>> +        zipHandle->handle = unzOpen(zipFilename);
> >>> +    else
> >>> +        zipHandle->handle = zipOpen(zipFilename,
> APPEND_STATUS_CREATE);
> >>> +
> >>> +    if (zipHandle->handle)
> >>> +        return zipHandle;
> >>> +
> >>> +    free(zipHandle);
> >>> +    return NULL;
> >>> +}
> >>> +
> >>> +
> >>> +
> >>> +int DFextZipClose(DFextZipHandleP zipHandle)
> >>> +{
> >>> +    int rc = 0;
> >>> +
> >>> +    if (zipHandle->handle) {
> >>> +        if (zipHandle->zipFlag)
> >>> +            rc = (unzClose(zipHandle->handle) == UNZ_OK);
> >>> +        else
> >>> +            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
> >>> +        zipHandle->handle = NULL;
> >>> +    }
> >>> +
> >>> +    free(zipHandle);
> >>> +    return rc ? 1 : -1;
> >>> +}
> >>> +
> >>> +
> >>> +
> >>> +int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName,
> >> const int maxName)
> >>> +{
> >>> +    int rc;
> >>> +
> >>> +
> >>> +    if (zipHandle->zipFlag) {
> >>> +        unz_file_info info;
> >>> +
> >>> +        // handling of first file and all others are different
> >>> +        if (zipHandle->zipFirst) {
> >>> +            rc = unzGoToFirstFile(zipHandle->handle);
> >>> +            zipHandle->zipFirst = 0;
> >>> +        }
> >>> +        else
> >>> +            rc = unzGoToNextFile(zipHandle->handle);
> >>> +
> >>> +        // Error or past last file
> >>> +        if (rc != UNZ_OK)
> >>> +            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
> >>> +
> >>> +        // get file name
> >>> +        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName,
> >> maxName, NULL, 0, NULL, 0) != UNZ_OK)
> >>> +            return -1;
> >>> +
> >>> +        // check for prefix "/" and if present skip file
> >>> +        if (entryName[strlen(entryName) - 1] == '/')
> >>> +            return DFextZipOpenNextFile(zipHandle, entryName,
> maxName);
> >>> +
> >>> +        // open Regular file
> >>> +        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
> >>> +            return -1;
> >>> +    }
> >>> +    else {
> >>> +        return -1; // Zip file is open in write-only mode
> >>> +    }
> >>> +
> >>> +    // ready to read
> >>> +    return 1;
> >>> +}
> >>> +
> >>> +int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char
> >> *entryName)
> >>> +{
> >>> +    zip_fileinfo fileinfo;
> >>> +    memset(&fileinfo, 0, sizeof(fileinfo));
> >>> +
> >>> +    if (zipHandle->zipFlag)
> >>> +        return -1; // Zip file is open in read-only mode
> >>> +
> >>> +    if (zipOpenNewFileInZip(zipHandle->handle,
> >>> +                            entryName,
> >>> +                            &fileinfo,
> >>> +                            NULL, 0,
> >>> +                            NULL, 0,
> >>> +                            NULL,
> >>> +                            Z_DEFLATED,
> >>> +                            Z_DEFAULT_COMPRESSION) != ZIP_OK) {
> >>> +        return -1;
> >>> +    }
> >>> +
> >>> +    return 1;
> >>> +}
> >>> +
> >>> +int DFextZipCloseFile(DFextZipHandleP zipHandle)
> >>> +{
> >>> +    if (zipHandle->zipFlag)
> >>> +        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1
> >> : 1;
> >>> +    else
> >>> +        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 :
> >> 1;
> >>> +}
> >>> +
> >>> +
> >>> +
> >>> +
> >>> +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf,
> const
> >> int maxLen)
> >>> +{
> >>> +    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
> >>> +}
> >>> +
> >>> +
> >>> +
> >>> +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void
> >> *buf, const int len)
> >>> +{
> >>> +    return (zipWriteInFileInZip(zipHandle->handle, buf, len) ==
> ZIP_OK)
> >> ? 1 : -1;
> >>> +}
> >>>
> >>
> >>
>
>

Re: [3/3] incubator-corinthia git commit: added wrapper for zip.

Posted by Dave Fisher <da...@comcast.net>.
HI Jani -

Just part of the Incubator process. If it is on the list then I am fine with what you outlined. Just trying to keep active as a Mentor.

I am more making the point that new files added by the team should be done in the proper way.

Thanks,
Dave

On Feb 12, 2015, at 12:57 PM, jan i wrote:

> On 12 February 2015 at 21:20, Dave Fisher <da...@comcast.net> wrote:
> 
>> JanI -
>> 
>> A question. Why is there a copyright in this file?
>> 
>> Did this file come from UX Productivity as part of the initial grant or
>> did you write it to contribute?
>> 
>> Depending on the answer action should be taken to comply with
>> http://www.apache.org/legal/src-headers.html
> 
> 
> I wrote it to contrbute, but actually the file dates back from before we
> entered incubator. I have a small set of files, that I worked on earlier
> which was not in trunk....
> 
> Peter is working on a scripts that goes through all files to replace the
> license with a new one, my reasoning was to keep everything identical until
> then. We have a jira for it.
> 
> If this procedure disturbs you then I will change that file specifically,
> and Peter might then need to make the script a bit more complex (check if
> header is already changed).
> 
> Just to be precise you have caught 1 of approx 10 files that have been
> added after we entered incubator (I have not counted, but it is my feeling).
> 
> No doubt we need to get all headers corrected. I had made the change
> already, had we not agreed that peter needs to do it.
> 
> rgds
> jan I.
> 
> 
>> 
>> Regards,
>> Dave
>> 
>> On Feb 11, 2015, at 10:56 AM, jani@apache.org wrote:
>> 
>>> added wrapper for zip.
>>> 
>>> 
>>> Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
>>> Commit:
>> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/768c5aad
>>> Tree:
>> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/768c5aad
>>> Diff:
>> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/768c5aad
>>> 
>>> Branch: refs/heads/experimentzip
>>> Commit: 768c5aad43a31a2e30c0cda101ffa12cf276fa23
>>> Parents: 0fbd721
>>> Author: jani <ja...@apache.org>
>>> Authored: Wed Feb 11 19:55:38 2015 +0100
>>> Committer: jani <ja...@apache.org>
>>> Committed: Wed Feb 11 19:55:38 2015 +0100
>>> 
>>> ----------------------------------------------------------------------
>>> DocFormats/platform/src/ZipWrapper.c | 146 ++++++++++++++++++++++++++++++
>>> 1 file changed, 146 insertions(+)
>>> ----------------------------------------------------------------------
>>> 
>>> 
>>> 
>> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/768c5aad/DocFormats/platform/src/ZipWrapper.c
>>> ----------------------------------------------------------------------
>>> diff --git a/DocFormats/platform/src/ZipWrapper.c
>> b/DocFormats/platform/src/ZipWrapper.c
>>> new file mode 100644
>>> index 0000000..14ed093
>>> --- /dev/null
>>> +++ b/DocFormats/platform/src/ZipWrapper.c
>>> @@ -0,0 +1,146 @@
>>> +// Copyright 2012-2014 UX Productivity Pty Ltd
>>> +//
>>> +// Licensed under the Apache License, Version 2.0 (the "License");
>>> +// you may not use this file except in compliance with the License.
>>> +// You may obtain a copy of the License at
>>> +//
>>> +// http://www.apache.org/licenses/LICENSE-2.0
>>> +//
>>> +// Unless required by applicable law or agreed to in writing, software
>>> +// distributed under the License is distributed on an "AS IS" BASIS,
>>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>>> +// See the License for the specific language governing permissions and
>>> +// limitations under the License.
>>> +#include <string.h>
>>> +#include <stdlib.h>
>>> +#include "DFPlatform.h"
>>> +#include "unzip.h"
>>> +#include "zip.h"
>>> +
>>> +
>>> +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
>>> +    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
>>> +
>>> +    // no more memory
>>> +    if (!zipHandle)
>>> +        return NULL;
>>> +
>>> +    // Open file
>>> +    zipHandle->zipFirst = 1;
>>> +    zipHandle->zipFlag = doUnzip;
>>> +    if (doUnzip)
>>> +        zipHandle->handle = unzOpen(zipFilename);
>>> +    else
>>> +        zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
>>> +
>>> +    if (zipHandle->handle)
>>> +        return zipHandle;
>>> +
>>> +    free(zipHandle);
>>> +    return NULL;
>>> +}
>>> +
>>> +
>>> +
>>> +int DFextZipClose(DFextZipHandleP zipHandle)
>>> +{
>>> +    int rc = 0;
>>> +
>>> +    if (zipHandle->handle) {
>>> +        if (zipHandle->zipFlag)
>>> +            rc = (unzClose(zipHandle->handle) == UNZ_OK);
>>> +        else
>>> +            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
>>> +        zipHandle->handle = NULL;
>>> +    }
>>> +
>>> +    free(zipHandle);
>>> +    return rc ? 1 : -1;
>>> +}
>>> +
>>> +
>>> +
>>> +int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName,
>> const int maxName)
>>> +{
>>> +    int rc;
>>> +
>>> +
>>> +    if (zipHandle->zipFlag) {
>>> +        unz_file_info info;
>>> +
>>> +        // handling of first file and all others are different
>>> +        if (zipHandle->zipFirst) {
>>> +            rc = unzGoToFirstFile(zipHandle->handle);
>>> +            zipHandle->zipFirst = 0;
>>> +        }
>>> +        else
>>> +            rc = unzGoToNextFile(zipHandle->handle);
>>> +
>>> +        // Error or past last file
>>> +        if (rc != UNZ_OK)
>>> +            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
>>> +
>>> +        // get file name
>>> +        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName,
>> maxName, NULL, 0, NULL, 0) != UNZ_OK)
>>> +            return -1;
>>> +
>>> +        // check for prefix "/" and if present skip file
>>> +        if (entryName[strlen(entryName) - 1] == '/')
>>> +            return DFextZipOpenNextFile(zipHandle, entryName, maxName);
>>> +
>>> +        // open Regular file
>>> +        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
>>> +            return -1;
>>> +    }
>>> +    else {
>>> +        return -1; // Zip file is open in write-only mode
>>> +    }
>>> +
>>> +    // ready to read
>>> +    return 1;
>>> +}
>>> +
>>> +int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char
>> *entryName)
>>> +{
>>> +    zip_fileinfo fileinfo;
>>> +    memset(&fileinfo, 0, sizeof(fileinfo));
>>> +
>>> +    if (zipHandle->zipFlag)
>>> +        return -1; // Zip file is open in read-only mode
>>> +
>>> +    if (zipOpenNewFileInZip(zipHandle->handle,
>>> +                            entryName,
>>> +                            &fileinfo,
>>> +                            NULL, 0,
>>> +                            NULL, 0,
>>> +                            NULL,
>>> +                            Z_DEFLATED,
>>> +                            Z_DEFAULT_COMPRESSION) != ZIP_OK) {
>>> +        return -1;
>>> +    }
>>> +
>>> +    return 1;
>>> +}
>>> +
>>> +int DFextZipCloseFile(DFextZipHandleP zipHandle)
>>> +{
>>> +    if (zipHandle->zipFlag)
>>> +        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1
>> : 1;
>>> +    else
>>> +        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 :
>> 1;
>>> +}
>>> +
>>> +
>>> +
>>> +
>>> +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const
>> int maxLen)
>>> +{
>>> +    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
>>> +}
>>> +
>>> +
>>> +
>>> +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void
>> *buf, const int len)
>>> +{
>>> +    return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK)
>> ? 1 : -1;
>>> +}
>>> 
>> 
>> 


Re: [3/3] incubator-corinthia git commit: added wrapper for zip.

Posted by jan i <ja...@apache.org>.
On 12 February 2015 at 21:20, Dave Fisher <da...@comcast.net> wrote:

> JanI -
>
> A question. Why is there a copyright in this file?
>
> Did this file come from UX Productivity as part of the initial grant or
> did you write it to contribute?
>
> Depending on the answer action should be taken to comply with
> http://www.apache.org/legal/src-headers.html


I wrote it to contrbute, but actually the file dates back from before we
entered incubator. I have a small set of files, that I worked on earlier
which was not in trunk....

Peter is working on a scripts that goes through all files to replace the
license with a new one, my reasoning was to keep everything identical until
then. We have a jira for it.

If this procedure disturbs you then I will change that file specifically,
and Peter might then need to make the script a bit more complex (check if
header is already changed).

Just to be precise you have caught 1 of approx 10 files that have been
added after we entered incubator (I have not counted, but it is my feeling).

No doubt we need to get all headers corrected. I had made the change
already, had we not agreed that peter needs to do it.

rgds
jan I.


>
> Regards,
> Dave
>
> On Feb 11, 2015, at 10:56 AM, jani@apache.org wrote:
>
> > added wrapper for zip.
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/768c5aad
> > Tree:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/768c5aad
> > Diff:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/768c5aad
> >
> > Branch: refs/heads/experimentzip
> > Commit: 768c5aad43a31a2e30c0cda101ffa12cf276fa23
> > Parents: 0fbd721
> > Author: jani <ja...@apache.org>
> > Authored: Wed Feb 11 19:55:38 2015 +0100
> > Committer: jani <ja...@apache.org>
> > Committed: Wed Feb 11 19:55:38 2015 +0100
> >
> > ----------------------------------------------------------------------
> > DocFormats/platform/src/ZipWrapper.c | 146 ++++++++++++++++++++++++++++++
> > 1 file changed, 146 insertions(+)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/768c5aad/DocFormats/platform/src/ZipWrapper.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/src/ZipWrapper.c
> b/DocFormats/platform/src/ZipWrapper.c
> > new file mode 100644
> > index 0000000..14ed093
> > --- /dev/null
> > +++ b/DocFormats/platform/src/ZipWrapper.c
> > @@ -0,0 +1,146 @@
> > +// Copyright 2012-2014 UX Productivity Pty Ltd
> > +//
> > +// Licensed under the Apache License, Version 2.0 (the "License");
> > +// you may not use this file except in compliance with the License.
> > +// You may obtain a copy of the License at
> > +//
> > +// http://www.apache.org/licenses/LICENSE-2.0
> > +//
> > +// Unless required by applicable law or agreed to in writing, software
> > +// distributed under the License is distributed on an "AS IS" BASIS,
> > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > +// See the License for the specific language governing permissions and
> > +// limitations under the License.
> > +#include <string.h>
> > +#include <stdlib.h>
> > +#include "DFPlatform.h"
> > +#include "unzip.h"
> > +#include "zip.h"
> > +
> > +
> > +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
> > +    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
> > +
> > +    // no more memory
> > +    if (!zipHandle)
> > +        return NULL;
> > +
> > +    // Open file
> > +    zipHandle->zipFirst = 1;
> > +    zipHandle->zipFlag = doUnzip;
> > +    if (doUnzip)
> > +        zipHandle->handle = unzOpen(zipFilename);
> > +    else
> > +        zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
> > +
> > +    if (zipHandle->handle)
> > +        return zipHandle;
> > +
> > +    free(zipHandle);
> > +    return NULL;
> > +}
> > +
> > +
> > +
> > +int DFextZipClose(DFextZipHandleP zipHandle)
> > +{
> > +    int rc = 0;
> > +
> > +    if (zipHandle->handle) {
> > +        if (zipHandle->zipFlag)
> > +            rc = (unzClose(zipHandle->handle) == UNZ_OK);
> > +        else
> > +            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
> > +        zipHandle->handle = NULL;
> > +    }
> > +
> > +    free(zipHandle);
> > +    return rc ? 1 : -1;
> > +}
> > +
> > +
> > +
> > +int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName,
> const int maxName)
> > +{
> > +    int rc;
> > +
> > +
> > +    if (zipHandle->zipFlag) {
> > +        unz_file_info info;
> > +
> > +        // handling of first file and all others are different
> > +        if (zipHandle->zipFirst) {
> > +            rc = unzGoToFirstFile(zipHandle->handle);
> > +            zipHandle->zipFirst = 0;
> > +        }
> > +        else
> > +            rc = unzGoToNextFile(zipHandle->handle);
> > +
> > +        // Error or past last file
> > +        if (rc != UNZ_OK)
> > +            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
> > +
> > +        // get file name
> > +        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName,
> maxName, NULL, 0, NULL, 0) != UNZ_OK)
> > +            return -1;
> > +
> > +        // check for prefix "/" and if present skip file
> > +        if (entryName[strlen(entryName) - 1] == '/')
> > +            return DFextZipOpenNextFile(zipHandle, entryName, maxName);
> > +
> > +        // open Regular file
> > +        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
> > +            return -1;
> > +    }
> > +    else {
> > +        return -1; // Zip file is open in write-only mode
> > +    }
> > +
> > +    // ready to read
> > +    return 1;
> > +}
> > +
> > +int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char
> *entryName)
> > +{
> > +    zip_fileinfo fileinfo;
> > +    memset(&fileinfo, 0, sizeof(fileinfo));
> > +
> > +    if (zipHandle->zipFlag)
> > +        return -1; // Zip file is open in read-only mode
> > +
> > +    if (zipOpenNewFileInZip(zipHandle->handle,
> > +                            entryName,
> > +                            &fileinfo,
> > +                            NULL, 0,
> > +                            NULL, 0,
> > +                            NULL,
> > +                            Z_DEFLATED,
> > +                            Z_DEFAULT_COMPRESSION) != ZIP_OK) {
> > +        return -1;
> > +    }
> > +
> > +    return 1;
> > +}
> > +
> > +int DFextZipCloseFile(DFextZipHandleP zipHandle)
> > +{
> > +    if (zipHandle->zipFlag)
> > +        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1
> : 1;
> > +    else
> > +        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 :
> 1;
> > +}
> > +
> > +
> > +
> > +
> > +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const
> int maxLen)
> > +{
> > +    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
> > +}
> > +
> > +
> > +
> > +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void
> *buf, const int len)
> > +{
> > +    return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK)
> ? 1 : -1;
> > +}
> >
>
>

Re: [3/3] incubator-corinthia git commit: added wrapper for zip.

Posted by Dave Fisher <da...@comcast.net>.
JanI -

A question. Why is there a copyright in this file?

Did this file come from UX Productivity as part of the initial grant or did you write it to contribute?

Depending on the answer action should be taken to comply with http://www.apache.org/legal/src-headers.html

Regards,
Dave

On Feb 11, 2015, at 10:56 AM, jani@apache.org wrote:

> added wrapper for zip.
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
> Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/768c5aad
> Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/768c5aad
> Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/768c5aad
> 
> Branch: refs/heads/experimentzip
> Commit: 768c5aad43a31a2e30c0cda101ffa12cf276fa23
> Parents: 0fbd721
> Author: jani <ja...@apache.org>
> Authored: Wed Feb 11 19:55:38 2015 +0100
> Committer: jani <ja...@apache.org>
> Committed: Wed Feb 11 19:55:38 2015 +0100
> 
> ----------------------------------------------------------------------
> DocFormats/platform/src/ZipWrapper.c | 146 ++++++++++++++++++++++++++++++
> 1 file changed, 146 insertions(+)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/768c5aad/DocFormats/platform/src/ZipWrapper.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/src/ZipWrapper.c b/DocFormats/platform/src/ZipWrapper.c
> new file mode 100644
> index 0000000..14ed093
> --- /dev/null
> +++ b/DocFormats/platform/src/ZipWrapper.c
> @@ -0,0 +1,146 @@
> +// Copyright 2012-2014 UX Productivity Pty Ltd
> +//
> +// Licensed under the Apache License, Version 2.0 (the "License");
> +// you may not use this file except in compliance with the License.
> +// You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +#include <string.h>
> +#include <stdlib.h>
> +#include "DFPlatform.h"
> +#include "unzip.h"
> +#include "zip.h"
> +
> +
> +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
> +    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
> + 
> +    // no more memory
> +    if (!zipHandle)
> +        return NULL;
> +
> +    // Open file
> +    zipHandle->zipFirst = 1;
> +    zipHandle->zipFlag = doUnzip;
> +    if (doUnzip)
> +        zipHandle->handle = unzOpen(zipFilename);
> +    else
> +        zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
> +
> +    if (zipHandle->handle)
> +        return zipHandle;
> +
> +    free(zipHandle);
> +    return NULL;
> +}
> +
> +
> +
> +int DFextZipClose(DFextZipHandleP zipHandle)
> +{
> +    int rc = 0;
> +
> +    if (zipHandle->handle) {
> +        if (zipHandle->zipFlag)
> +            rc = (unzClose(zipHandle->handle) == UNZ_OK);
> +        else
> +            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
> +        zipHandle->handle = NULL;
> +    }
> +
> +    free(zipHandle);
> +    return rc ? 1 : -1;
> +}
> +
> +
> +
> +int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName)
> +{
> +    int rc;
> +
> +
> +    if (zipHandle->zipFlag) {
> +        unz_file_info info;
> +
> +        // handling of first file and all others are different
> +        if (zipHandle->zipFirst) {
> +            rc = unzGoToFirstFile(zipHandle->handle);
> +            zipHandle->zipFirst = 0;
> +        }
> +        else
> +            rc = unzGoToNextFile(zipHandle->handle);
> +
> +        // Error or past last file
> +        if (rc != UNZ_OK)
> +            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
> +
> +        // get file name
> +        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName, maxName, NULL, 0, NULL, 0) != UNZ_OK)
> +            return -1;
> +
> +        // check for prefix "/" and if present skip file
> +        if (entryName[strlen(entryName) - 1] == '/')
> +            return DFextZipOpenNextFile(zipHandle, entryName, maxName);
> +
> +        // open Regular file
> +        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
> +            return -1;
> +    }
> +    else {
> +        return -1; // Zip file is open in write-only mode
> +    }
> +
> +    // ready to read
> +    return 1;
> +}
> +
> +int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
> +{
> +    zip_fileinfo fileinfo;
> +    memset(&fileinfo, 0, sizeof(fileinfo));
> +
> +    if (zipHandle->zipFlag)
> +        return -1; // Zip file is open in read-only mode
> +
> +    if (zipOpenNewFileInZip(zipHandle->handle,
> +                            entryName,
> +                            &fileinfo,
> +                            NULL, 0,
> +                            NULL, 0,
> +                            NULL,
> +                            Z_DEFLATED,
> +                            Z_DEFAULT_COMPRESSION) != ZIP_OK) {
> +        return -1;
> +    }
> +
> +    return 1;
> +}
> +
> +int DFextZipCloseFile(DFextZipHandleP zipHandle)
> +{
> +    if (zipHandle->zipFlag)
> +        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1 : 1;
> +    else
> +        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 : 1;
> +}
> +
> +
> + 
> +
> +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen)
> +{
> +    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
> +}
> +
> +
> +
> +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
> +{
> +    return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
> +}
> 


[3/3] incubator-corinthia git commit: added wrapper for zip.

Posted by ja...@apache.org.
added wrapper for zip.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/768c5aad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/768c5aad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/768c5aad

Branch: refs/heads/experimentzip
Commit: 768c5aad43a31a2e30c0cda101ffa12cf276fa23
Parents: 0fbd721
Author: jani <ja...@apache.org>
Authored: Wed Feb 11 19:55:38 2015 +0100
Committer: jani <ja...@apache.org>
Committed: Wed Feb 11 19:55:38 2015 +0100

----------------------------------------------------------------------
 DocFormats/platform/src/ZipWrapper.c | 146 ++++++++++++++++++++++++++++++
 1 file changed, 146 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/768c5aad/DocFormats/platform/src/ZipWrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/ZipWrapper.c b/DocFormats/platform/src/ZipWrapper.c
new file mode 100644
index 0000000..14ed093
--- /dev/null
+++ b/DocFormats/platform/src/ZipWrapper.c
@@ -0,0 +1,146 @@
+// Copyright 2012-2014 UX Productivity Pty Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#include <string.h>
+#include <stdlib.h>
+#include "DFPlatform.h"
+#include "unzip.h"
+#include "zip.h"
+
+
+DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
+    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
+ 
+    // no more memory
+    if (!zipHandle)
+        return NULL;
+
+    // Open file
+    zipHandle->zipFirst = 1;
+    zipHandle->zipFlag = doUnzip;
+    if (doUnzip)
+        zipHandle->handle = unzOpen(zipFilename);
+    else
+        zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
+
+    if (zipHandle->handle)
+        return zipHandle;
+
+    free(zipHandle);
+    return NULL;
+}
+
+
+
+int DFextZipClose(DFextZipHandleP zipHandle)
+{
+    int rc = 0;
+
+    if (zipHandle->handle) {
+        if (zipHandle->zipFlag)
+            rc = (unzClose(zipHandle->handle) == UNZ_OK);
+        else
+            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
+        zipHandle->handle = NULL;
+    }
+
+    free(zipHandle);
+    return rc ? 1 : -1;
+}
+
+
+
+int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName)
+{
+    int rc;
+
+
+    if (zipHandle->zipFlag) {
+        unz_file_info info;
+
+        // handling of first file and all others are different
+        if (zipHandle->zipFirst) {
+            rc = unzGoToFirstFile(zipHandle->handle);
+            zipHandle->zipFirst = 0;
+        }
+        else
+            rc = unzGoToNextFile(zipHandle->handle);
+
+        // Error or past last file
+        if (rc != UNZ_OK)
+            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
+
+        // get file name
+        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName, maxName, NULL, 0, NULL, 0) != UNZ_OK)
+            return -1;
+
+        // check for prefix "/" and if present skip file
+        if (entryName[strlen(entryName) - 1] == '/')
+            return DFextZipOpenNextFile(zipHandle, entryName, maxName);
+
+        // open Regular file
+        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
+            return -1;
+    }
+    else {
+        return -1; // Zip file is open in write-only mode
+    }
+
+    // ready to read
+    return 1;
+}
+
+int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
+{
+    zip_fileinfo fileinfo;
+    memset(&fileinfo, 0, sizeof(fileinfo));
+
+    if (zipHandle->zipFlag)
+        return -1; // Zip file is open in read-only mode
+
+    if (zipOpenNewFileInZip(zipHandle->handle,
+                            entryName,
+                            &fileinfo,
+                            NULL, 0,
+                            NULL, 0,
+                            NULL,
+                            Z_DEFLATED,
+                            Z_DEFAULT_COMPRESSION) != ZIP_OK) {
+        return -1;
+    }
+
+    return 1;
+}
+
+int DFextZipCloseFile(DFextZipHandleP zipHandle)
+{
+    if (zipHandle->zipFlag)
+        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1 : 1;
+    else
+        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 : 1;
+}
+
+
+ 
+
+int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen)
+{
+    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
+}
+
+
+
+int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
+{
+    return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
+}


[2/3] incubator-corinthia git commit: Merge branch 'master' into experimentzip

Posted by ja...@apache.org.
Merge branch 'master' into experimentzip


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/0fbd7214
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/0fbd7214
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/0fbd7214

Branch: refs/heads/experimentzip
Commit: 0fbd72147fba40bfd83c32aee684b4a039776ca5
Parents: 7411867 c94ae5d
Author: jani <ja...@apache.org>
Authored: Wed Feb 11 18:18:36 2015 +0100
Committer: jani <ja...@apache.org>
Committed: Wed Feb 11 18:18:36 2015 +0100

----------------------------------------------------------------------
 build/build_instructions.txt | Bin 0 -> 7208 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------