This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <boost/function.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
static size_t
get_from_zip_url_data (void* buffer, size_t size, size_t nmemb, void* stream)
static size_t
get_from_zip_url_data (void* buffer, size_t size, size_t nmemb, void* stream)
/* Download the ZIP file to temp_zip */
CURL* curl = curl_easy_init ();
curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
/* Download the ZIP file to temp_zip */
CURL* curl = curl_easy_init ();
curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
ScopedTemporary temp_zip;
FILE* f = temp_zip.open ("wb");
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data);
curl_easy_setopt (curl, CURLOPT_WRITEDATA, f);
curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0);
ScopedTemporary temp_zip;
FILE* f = temp_zip.open ("wb");
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data);
curl_easy_setopt (curl, CURLOPT_WRITEDATA, f);
curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0);
struct zip* zip = zip_open (temp_zip.c_str(), 0, 0);
if (!zip) {
return optional<string> (_("Could not open downloaded ZIP file"));
}
struct zip* zip = zip_open (temp_zip.c_str(), 0, 0);
if (!zip) {
return optional<string> (_("Could not open downloaded ZIP file"));
}
struct zip_file* zip_file = zip_fopen (zip, file.c_str(), 0);
if (!zip_file) {
return optional<string> (_("Unexpected ZIP file contents"));
}
struct zip_file* zip_file = zip_fopen (zip, file.c_str(), 0);
if (!zip_file) {
return optional<string> (_("Unexpected ZIP file contents"));
}
if (line.length() > 55) {
string const file = line.substr (55);
if (file != "." && file != "..") {
if (line.length() > 55) {
string const file = line.substr (55);
if (file != "." && file != "..") {