Mercurial > hg > orthanc
annotate Core/Compression/HierarchicalZipWriter.cpp @ 2419:f51e9e852299
add tags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 06 Oct 2017 17:26:15 +0200 |
parents | a3a65de1840f |
children | 878b59270859 |
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 |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2244
a3a65de1840f
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
5 * Copyright (C) 2017 Osimis, Belgium |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * License, or (at your option) any later version. |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * 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
|
16 * 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
|
17 * 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
|
18 * 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
|
19 * 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
|
20 * 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
|
21 * 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
|
22 * in the program, then also delete it here. |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * 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
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * 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
|
27 * General Public License for more details. |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * 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
|
30 * 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
|
31 **/ |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
34 #include "../PrecompiledHeaders.h" |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "HierarchicalZipWriter.h" |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include "../Toolbox.h" |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #include "../OrthancException.h" |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 #include <boost/lexical_cast.hpp> |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 namespace Orthanc |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 std::string HierarchicalZipWriter::Index::KeepAlphanumeric(const std::string& source) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 std::string result; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 bool lastSpace = false; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 result.reserve(source.size()); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 for (size_t i = 0; i < source.size(); i++) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
53 char c = source[i]; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
54 if (c == '^') |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
55 c = ' '; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
56 |
1334 | 57 if (c <= 127 && |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
58 c >= 0) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
60 if (isspace(c)) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 if (!lastSpace) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 lastSpace = true; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 result.push_back(' '); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 } |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
68 else if (isalnum(c) || |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
69 c == '.' || |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
70 c == '_') |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
72 result.push_back(c); |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 lastSpace = false; |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 return Toolbox::StripSpaces(result); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 std::string HierarchicalZipWriter::Index::GetCurrentDirectoryPath() const |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 std::string result; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 Stack::const_iterator it = stack_.begin(); |
656 | 86 ++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
|
87 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 while (it != stack_.end()) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 result += (*it)->name_ + "/"; |
656 | 91 ++it; |
247
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 return result; |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 std::string HierarchicalZipWriter::Index::EnsureUniqueFilename(const char* filename) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 std::string standardized = KeepAlphanumeric(filename); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 Directory& d = *stack_.back(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 Directory::Content::iterator it = d.content_.find(standardized); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 if (it == d.content_.end()) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 d.content_[standardized] = 1; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 return standardized; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 else |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 it->second++; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 return standardized + "-" + boost::lexical_cast<std::string>(it->second); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 HierarchicalZipWriter::Index::Index() |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 stack_.push_back(new Directory); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 HierarchicalZipWriter::Index::~Index() |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
656 | 123 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
|
124 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 delete *it; |
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 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
249 | 129 std::string HierarchicalZipWriter::Index::OpenFile(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 return GetCurrentDirectoryPath() + EnsureUniqueFilename(name); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 |
249 | 134 void HierarchicalZipWriter::Index::OpenDirectory(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 std::string d = EnsureUniqueFilename(name); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 // Push the new directory onto the stack |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 stack_.push_back(new Directory); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 stack_.back()->name_ = d; |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 void HierarchicalZipWriter::Index::CloseDirectory() |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 if (IsRoot()) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 // Cannot close the root node |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 delete stack_.back(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 stack_.pop_back(); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 HierarchicalZipWriter::HierarchicalZipWriter(const char* path) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 writer_.SetOutputPath(path); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 writer_.Open(); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 HierarchicalZipWriter::~HierarchicalZipWriter() |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 writer_.Close(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
249 | 167 void HierarchicalZipWriter::OpenFile(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
249 | 169 std::string p = indexer_.OpenFile(name); |
170 writer_.OpenFile(p.c_str()); | |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 |
249 | 173 void HierarchicalZipWriter::OpenDirectory(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 { |
249 | 175 indexer_.OpenDirectory(name); |
247
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 void HierarchicalZipWriter::CloseDirectory() |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 indexer_.CloseDirectory(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 } |