Mercurial > hg > orthanc
annotate Core/Compression/HierarchicalZipWriter.cpp @ 675:9a8716686f18
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Dec 2013 13:50:21 +0100 |
parents | 08eca5d86aad |
children | 2d0a347e8cfc |
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 |
398 | 3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Belgium |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #include "HierarchicalZipWriter.h" |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "../Toolbox.h" |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include "../OrthancException.h" |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #include <boost/lexical_cast.hpp> |
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 namespace Orthanc |
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 std::string HierarchicalZipWriter::Index::KeepAlphanumeric(const std::string& source) |
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 result; |
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 bool lastSpace = false; |
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 result.reserve(source.size()); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 for (size_t i = 0; i < source.size(); i++) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
51 char c = source[i]; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
52 if (c == '^') |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
53 c = ' '; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
54 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
55 if (c < 128 && |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
56 c >= 0) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
58 if (isspace(c)) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 if (!lastSpace) |
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 lastSpace = true; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 result.push_back(' '); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 } |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
66 else if (isalnum(c) || |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
67 c == '.' || |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
68 c == '_') |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
70 result.push_back(c); |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 lastSpace = false; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 } |
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 return Toolbox::StripSpaces(result); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 std::string HierarchicalZipWriter::Index::GetCurrentDirectoryPath() const |
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 result; |
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 Stack::const_iterator it = stack_.begin(); |
656 | 84 ++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
|
85 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 while (it != stack_.end()) |
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 result += (*it)->name_ + "/"; |
656 | 89 ++it; |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 } |
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 return result; |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 std::string HierarchicalZipWriter::Index::EnsureUniqueFilename(const char* filename) |
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 standardized = KeepAlphanumeric(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 Directory& d = *stack_.back(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 Directory::Content::iterator it = d.content_.find(standardized); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 if (it == d.content_.end()) |
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 d.content_[standardized] = 1; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 return standardized; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 else |
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 it->second++; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 return standardized + "-" + boost::lexical_cast<std::string>(it->second); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
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 HierarchicalZipWriter::Index::Index() |
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 stack_.push_back(new Directory); |
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 |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 HierarchicalZipWriter::Index::~Index() |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 { |
656 | 121 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
|
122 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 delete *it; |
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 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
249 | 127 std::string HierarchicalZipWriter::Index::OpenFile(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 return GetCurrentDirectoryPath() + EnsureUniqueFilename(name); |
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 |
249 | 132 void HierarchicalZipWriter::Index::OpenDirectory(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 std::string d = EnsureUniqueFilename(name); |
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 // Push the new directory onto the stack |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 stack_.push_back(new Directory); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 stack_.back()->name_ = d; |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 } |
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 void HierarchicalZipWriter::Index::CloseDirectory() |
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 if (IsRoot()) |
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 // Cannot close the root node |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 } |
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 delete stack_.back(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 stack_.pop_back(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 } |
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 HierarchicalZipWriter::HierarchicalZipWriter(const char* path) |
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 writer_.SetOutputPath(path); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 writer_.Open(); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 } |
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 HierarchicalZipWriter::~HierarchicalZipWriter() |
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 writer_.Close(); |
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 |
249 | 165 void HierarchicalZipWriter::OpenFile(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 { |
249 | 167 std::string p = indexer_.OpenFile(name); |
168 writer_.OpenFile(p.c_str()); | |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 } |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 |
249 | 171 void HierarchicalZipWriter::OpenDirectory(const char* name) |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 { |
249 | 173 indexer_.OpenDirectory(name); |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 } |
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 void HierarchicalZipWriter::CloseDirectory() |
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 indexer_.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 } |