Mercurial > hg > orthanc
annotate Resources/EmbedResources.py @ 1465:905842836ad4
sample Lua script to write DICOM series to disk
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 27 Jul 2015 17:33:47 +0200 |
parents | 601d34afdab9 |
children | 5068de14eef1 |
rev | line source |
---|---|
143 | 1 # Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1204
diff
changeset
|
2 # Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1204
diff
changeset
|
3 # Department, University Hospital of Liege, Belgium |
143 | 4 # |
5 # This program is free software: you can redistribute it and/or | |
6 # modify it under the terms of the GNU General Public License as | |
7 # published by the Free Software Foundation, either version 3 of the | |
8 # License, or (at your option) any later version. | |
9 # | |
10 # In addition, as a special exception, the copyright holders of this | |
11 # program give permission to link the code of its release with the | |
12 # OpenSSL project's "OpenSSL" library (or with modified versions of it | |
13 # that use the same license as the "OpenSSL" library), and distribute | |
14 # the linked executables. You must obey the GNU General Public License | |
15 # in all respects for all of the code used other than "OpenSSL". If you | |
16 # modify file(s) with this exception, you may extend this exception to | |
17 # your version of the file(s), but you are not obligated to do so. If | |
18 # you do not wish to do so, delete this exception statement from your | |
19 # version. If you delete this exception statement from all source files | |
20 # in the program, then also delete it here. | |
21 # | |
22 # This program is distributed in the hope that it will be useful, but | |
23 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
25 # General Public License for more details. | |
26 # | |
27 # You should have received a copy of the GNU General Public License | |
28 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
29 | |
30 | |
0 | 31 import sys |
32 import os | |
33 import os.path | |
34 import pprint | |
129 | 35 import re |
0 | 36 |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
37 UPCASE_CHECK = True |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
38 ARGS = [] |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
39 for i in range(len(sys.argv)): |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
40 if not sys.argv[i].startswith('--'): |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
41 ARGS.append(sys.argv[i]) |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
42 elif sys.argv[i].lower() == '--no-upcase-check': |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
43 UPCASE_CHECK = False |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
44 |
326 | 45 if len(ARGS) < 2 or len(ARGS) % 2 != 0: |
46 print ('Usage:') | |
47 print ('python %s [--no-upcase-check] <TargetBaseFilename> [ <Name> <Source> ]*' % sys.argv[0]) | |
48 exit(-1) | |
49 | |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
50 TARGET_BASE_FILENAME = ARGS[1] |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
51 SOURCES = ARGS[2:] |
0 | 52 |
53 try: | |
54 # Make sure the destination directory exists | |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
55 os.makedirs(os.path.normpath(os.path.join(TARGET_BASE_FILENAME, '..'))) |
0 | 56 except: |
57 pass | |
58 | |
59 | |
60 ##################################################################### | |
61 ## Read each resource file | |
62 ##################################################################### | |
63 | |
129 | 64 def CheckNoUpcase(s): |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
65 global UPCASE_CHECK |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
66 if (UPCASE_CHECK and |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
67 re.search('[A-Z]', s) != None): |
129 | 68 raise Exception("Path in a directory with an upcase letter: %s" % s) |
69 | |
0 | 70 resources = {} |
71 | |
72 counter = 0 | |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
73 i = 0 |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
74 while i < len(SOURCES): |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
75 resourceName = SOURCES[i].upper() |
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
76 pathName = SOURCES[i + 1] |
0 | 77 |
78 if not os.path.exists(pathName): | |
79 raise Exception("Non existing path: %s" % pathName) | |
80 | |
81 if resourceName in resources: | |
82 raise Exception("Twice the same resource: " + resourceName) | |
83 | |
84 if os.path.isdir(pathName): | |
85 # The resource is a directory: Recursively explore its files | |
86 content = {} | |
87 for root, dirs, files in os.walk(pathName): | |
88 base = os.path.relpath(root, pathName) | |
1204
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
89 |
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
90 # Fix issue #24 (Build fails on OSX when directory has .DS_Store files): |
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
91 # Ignore folders whose name starts with a dot (".") |
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
92 if base.find('/.') != -1: |
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
93 print('Ignoring folder: %s' % root) |
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
94 continue |
6babe0c7aa27
Fix issue #24 (Build fails on OSX when directory has .DS_Store files)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
95 |
0 | 96 for f in files: |
97 if f.find('~') == -1: # Ignore Emacs backup files | |
98 if base == '.': | |
129 | 99 r = f |
0 | 100 else: |
129 | 101 r = os.path.join(base, f) |
0 | 102 |
129 | 103 CheckNoUpcase(r) |
20 | 104 r = '/' + r.replace('\\', '/') |
0 | 105 if r in content: |
106 raise Exception("Twice the same filename (check case): " + r) | |
107 | |
108 content[r] = { | |
109 'Filename' : os.path.join(root, f), | |
110 'Index' : counter | |
111 } | |
112 counter += 1 | |
113 | |
114 resources[resourceName] = { | |
115 'Type' : 'Directory', | |
116 'Files' : content | |
117 } | |
118 | |
119 elif os.path.isfile(pathName): | |
120 resources[resourceName] = { | |
121 'Type' : 'File', | |
122 'Index' : counter, | |
123 'Filename' : pathName | |
124 } | |
125 counter += 1 | |
126 | |
127 else: | |
128 raise Exception("Not a regular file, nor a directory: " + pathName) | |
129 | |
130 i += 2 | |
131 | |
132 #pprint.pprint(resources) | |
133 | |
134 | |
135 ##################################################################### | |
136 ## Write .h header | |
137 ##################################################################### | |
138 | |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
139 header = open(TARGET_BASE_FILENAME + '.h', 'w') |
0 | 140 |
141 header.write(""" | |
142 #pragma once | |
143 | |
144 #include <string> | |
323
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
145 #include <list> |
0 | 146 |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
147 namespace Orthanc |
0 | 148 { |
149 namespace EmbeddedResources | |
150 { | |
151 enum FileResourceId | |
152 { | |
153 """) | |
154 | |
155 isFirst = True | |
156 for name in resources: | |
157 if resources[name]['Type'] == 'File': | |
158 if isFirst: | |
159 isFirst = False | |
160 else: | |
161 header.write(',\n') | |
162 header.write(' %s' % name) | |
163 | |
164 header.write(""" | |
165 }; | |
166 | |
167 enum DirectoryResourceId | |
168 { | |
169 """) | |
170 | |
171 isFirst = True | |
172 for name in resources: | |
173 if resources[name]['Type'] == 'Directory': | |
174 if isFirst: | |
175 isFirst = False | |
176 else: | |
177 header.write(',\n') | |
178 header.write(' %s' % name) | |
179 | |
180 header.write(""" | |
181 }; | |
182 | |
183 const void* GetFileResourceBuffer(FileResourceId id); | |
184 size_t GetFileResourceSize(FileResourceId id); | |
185 void GetFileResource(std::string& result, FileResourceId id); | |
186 | |
187 const void* GetDirectoryResourceBuffer(DirectoryResourceId id, const char* path); | |
188 size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path); | |
189 void GetDirectoryResource(std::string& result, DirectoryResourceId id, const char* path); | |
323
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
190 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
191 void ListResources(std::list<std::string>& result, DirectoryResourceId id); |
0 | 192 } |
193 } | |
194 """) | |
195 header.close() | |
196 | |
197 | |
198 | |
199 ##################################################################### | |
200 ## Write the resource content in the .cpp source | |
201 ##################################################################### | |
202 | |
55 | 203 PYTHON_MAJOR_VERSION = sys.version_info[0] |
204 | |
0 | 205 def WriteResource(cpp, item): |
206 cpp.write(' static const uint8_t resource%dBuffer[] = {' % item['Index']) | |
207 | |
208 f = open(item['Filename'], "rb") | |
209 content = f.read() | |
210 f.close() | |
211 | |
212 # http://stackoverflow.com/a/1035360 | |
213 pos = 0 | |
214 for b in content: | |
55 | 215 if PYTHON_MAJOR_VERSION == 2: |
216 c = ord(b[0]) | |
217 else: | |
218 c = b | |
219 | |
0 | 220 if pos > 0: |
221 cpp.write(', ') | |
222 | |
223 if (pos % 16) == 0: | |
224 cpp.write('\n ') | |
225 | |
55 | 226 if c < 0: |
0 | 227 raise Exception("Internal error") |
228 | |
55 | 229 cpp.write("0x%02x" % c) |
0 | 230 pos += 1 |
231 | |
1377
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
232 # Zero-size array are disallowed, so we put one single void character in it. |
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
233 if pos == 0: |
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
234 cpp.write(' 0') |
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
235 |
0 | 236 cpp.write(' };\n') |
237 cpp.write(' static const size_t resource%dSize = %d;\n' % (item['Index'], pos)) | |
238 | |
239 | |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
240 cpp = open(TARGET_BASE_FILENAME + '.cpp', 'w') |
0 | 241 |
242 cpp.write(""" | |
243 #include "%s.h" | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
244 #include "%s/Core/OrthancException.h" |
0 | 245 |
246 #include <stdint.h> | |
247 #include <string.h> | |
248 | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
249 namespace Orthanc |
0 | 250 { |
251 namespace EmbeddedResources | |
252 { | |
325
71d30b9ce801
ignore upcase check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
253 """ % (os.path.basename(TARGET_BASE_FILENAME), |
0 | 254 os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))) |
255 | |
256 | |
257 for name in resources: | |
258 if resources[name]['Type'] == 'File': | |
259 WriteResource(cpp, resources[name]) | |
260 else: | |
261 for f in resources[name]['Files']: | |
262 WriteResource(cpp, resources[name]['Files'][f]) | |
263 | |
264 | |
265 | |
266 ##################################################################### | |
267 ## Write the accessors to the file resources in .cpp | |
268 ##################################################################### | |
269 | |
270 cpp.write(""" | |
271 const void* GetFileResourceBuffer(FileResourceId id) | |
272 { | |
273 switch (id) | |
274 { | |
275 """) | |
276 for name in resources: | |
277 if resources[name]['Type'] == 'File': | |
278 cpp.write(' case %s:\n' % name) | |
279 cpp.write(' return resource%dBuffer;\n' % resources[name]['Index']) | |
280 | |
281 cpp.write(""" | |
282 default: | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
283 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 284 } |
285 } | |
286 | |
287 size_t GetFileResourceSize(FileResourceId id) | |
288 { | |
289 switch (id) | |
290 { | |
291 """) | |
292 | |
293 for name in resources: | |
294 if resources[name]['Type'] == 'File': | |
295 cpp.write(' case %s:\n' % name) | |
296 cpp.write(' return resource%dSize;\n' % resources[name]['Index']) | |
297 | |
298 cpp.write(""" | |
299 default: | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
300 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 301 } |
302 } | |
303 """) | |
304 | |
305 | |
306 | |
307 ##################################################################### | |
308 ## Write the accessors to the directory resources in .cpp | |
309 ##################################################################### | |
310 | |
311 cpp.write(""" | |
312 const void* GetDirectoryResourceBuffer(DirectoryResourceId id, const char* path) | |
313 { | |
314 switch (id) | |
315 { | |
316 """) | |
317 | |
318 for name in resources: | |
319 if resources[name]['Type'] == 'Directory': | |
320 cpp.write(' case %s:\n' % name) | |
321 isFirst = True | |
322 for path in resources[name]['Files']: | |
323 cpp.write(' if (!strcmp(path, "%s"))\n' % path) | |
324 cpp.write(' return resource%dBuffer;\n' % resources[name]['Files'][path]['Index']) | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
325 cpp.write(' throw OrthancException("Unknown path in a directory resource");\n\n') |
0 | 326 |
327 cpp.write(""" default: | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
328 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 329 } |
330 } | |
331 | |
332 size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path) | |
333 { | |
334 switch (id) | |
335 { | |
336 """) | |
337 | |
338 for name in resources: | |
339 if resources[name]['Type'] == 'Directory': | |
340 cpp.write(' case %s:\n' % name) | |
341 isFirst = True | |
342 for path in resources[name]['Files']: | |
343 cpp.write(' if (!strcmp(path, "%s"))\n' % path) | |
344 cpp.write(' return resource%dSize;\n' % resources[name]['Files'][path]['Index']) | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
345 cpp.write(' throw OrthancException("Unknown path in a directory resource");\n\n') |
0 | 346 |
347 cpp.write(""" default: | |
64
71c4a4abe90b
renaming of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
348 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 349 } |
350 } | |
351 """) | |
352 | |
353 | |
354 | |
355 | |
356 ##################################################################### | |
323
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
357 ## List the resources in a directory |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
358 ##################################################################### |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
359 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
360 cpp.write(""" |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
361 void ListResources(std::list<std::string>& result, DirectoryResourceId id) |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
362 { |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
363 result.clear(); |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
364 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
365 switch (id) |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
366 { |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
367 """) |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
368 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
369 for name in resources: |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
370 if resources[name]['Type'] == 'Directory': |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
371 cpp.write(' case %s:\n' % name) |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
372 for path in sorted(resources[name]['Files']): |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
373 cpp.write(' result.push_back("%s");\n' % path) |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
374 cpp.write(' break;\n\n') |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
375 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
376 cpp.write(""" default: |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
377 throw OrthancException(ErrorCode_ParameterOutOfRange); |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
378 } |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
379 } |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
380 """) |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
381 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
382 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
383 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
384 |
052dede32761
list files in resource directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
385 ##################################################################### |
0 | 386 ## Write the convenience wrappers in .cpp |
387 ##################################################################### | |
388 | |
389 cpp.write(""" | |
390 void GetFileResource(std::string& result, FileResourceId id) | |
391 { | |
392 size_t size = GetFileResourceSize(id); | |
393 result.resize(size); | |
394 if (size > 0) | |
395 memcpy(&result[0], GetFileResourceBuffer(id), size); | |
396 } | |
397 | |
398 void GetDirectoryResource(std::string& result, DirectoryResourceId id, const char* path) | |
399 { | |
400 size_t size = GetDirectoryResourceSize(id, path); | |
401 result.resize(size); | |
402 if (size > 0) | |
403 memcpy(&result[0], GetDirectoryResourceBuffer(id, path), size); | |
404 } | |
405 } | |
406 } | |
407 """) | |
408 cpp.close() |