annotate Core/Compression/HierarchicalZipWriter.cpp @ 1739:df331354cea2

include binary in ToJson
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 22 Oct 2015 19:00:32 +0200
parents 7f0aa3c0f659
children b1291df2f780
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
4 * Department, University Hospital of Liege, Belgium
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
33 #include "../PrecompiledHeaders.h"
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "HierarchicalZipWriter.h"
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../Toolbox.h"
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../OrthancException.h"
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include <boost/lexical_cast.hpp>
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 std::string HierarchicalZipWriter::Index::KeepAlphanumeric(const std::string& source)
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 std::string result;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 bool lastSpace = false;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 result.reserve(source.size());
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 for (size_t i = 0; i < source.size(); i++)
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
250
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
52 char c = source[i];
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
53 if (c == '^')
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
54 c = ' ';
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
55
1334
7f0aa3c0f659 code improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
56 if (c <= 127 &&
250
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
57 c >= 0)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
250
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
59 if (isspace(c))
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 if (!lastSpace)
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 lastSpace = true;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 result.push_back(' ');
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
250
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
67 else if (isalnum(c) ||
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
68 c == '.' ||
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
69 c == '_')
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
250
f23318b11b39 creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
71 result.push_back(c);
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 lastSpace = false;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 return Toolbox::StripSpaces(result);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 std::string HierarchicalZipWriter::Index::GetCurrentDirectoryPath() const
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 std::string result;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 Stack::const_iterator it = stack_.begin();
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 398
diff changeset
85 ++it; // Skip the root node (to avoid absolute paths)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 while (it != stack_.end())
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 result += (*it)->name_ + "/";
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 398
diff changeset
90 ++it;
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return result;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 std::string HierarchicalZipWriter::Index::EnsureUniqueFilename(const char* filename)
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 std::string standardized = KeepAlphanumeric(filename);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 Directory& d = *stack_.back();
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 Directory::Content::iterator it = d.content_.find(standardized);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 if (it == d.content_.end())
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 d.content_[standardized] = 1;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 return standardized;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 else
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 it->second++;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 return standardized + "-" + boost::lexical_cast<std::string>(it->second);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 HierarchicalZipWriter::Index::Index()
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 stack_.push_back(new Directory);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 HierarchicalZipWriter::Index::~Index()
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 398
diff changeset
122 for (Stack::iterator it = stack_.begin(); it != stack_.end(); ++it)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 delete *it;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
249
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
128 std::string HierarchicalZipWriter::Index::OpenFile(const char* name)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 return GetCurrentDirectoryPath() + EnsureUniqueFilename(name);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
249
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
133 void HierarchicalZipWriter::Index::OpenDirectory(const char* name)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 std::string d = EnsureUniqueFilename(name);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 // Push the new directory onto the stack
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 stack_.push_back(new Directory);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 stack_.back()->name_ = d;
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 void HierarchicalZipWriter::Index::CloseDirectory()
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 if (IsRoot())
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 // Cannot close the root node
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 throw OrthancException(ErrorCode_BadSequenceOfCalls);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 delete stack_.back();
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 stack_.pop_back();
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 HierarchicalZipWriter::HierarchicalZipWriter(const char* path)
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 writer_.SetOutputPath(path);
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 writer_.Open();
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 HierarchicalZipWriter::~HierarchicalZipWriter()
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 writer_.Close();
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
249
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
166 void HierarchicalZipWriter::OpenFile(const char* name)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
249
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
168 std::string p = indexer_.OpenFile(name);
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
169 writer_.OpenFile(p.c_str());
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
249
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
172 void HierarchicalZipWriter::OpenDirectory(const char* name)
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
249
5694365ecb96 fixes for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
174 indexer_.OpenDirectory(name);
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 void HierarchicalZipWriter::CloseDirectory()
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 indexer_.CloseDirectory();
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 }