OLD | NEW |
1 // Copyright 2015 The Bazel Authors. All rights reserved. | 1 // Copyright 2015 The Bazel Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 u1* buf = reinterpret_cast<u1*>(malloc(size)); | 77 u1* buf = reinterpret_cast<u1*>(malloc(size)); |
78 u1* classdata_out = buf; | 78 u1* classdata_out = buf; |
79 if (!StripClass(buf, data, size)) { | 79 if (!StripClass(buf, data, size)) { |
80 free(classdata_out); | 80 free(classdata_out); |
81 return; | 81 return; |
82 } | 82 } |
83 u1* q = builder->NewFile(filename, 0); | 83 u1* q = builder->NewFile(filename, 0); |
84 size_t out_length = buf - classdata_out; | 84 size_t out_length = buf - classdata_out; |
85 memcpy(q, classdata_out, out_length); | 85 memcpy(q, classdata_out, out_length); |
86 builder->FinishFile(out_length); | 86 builder->FinishFile(out_length, false, true); |
87 free(classdata_out); | 87 free(classdata_out); |
88 } | 88 } |
89 | 89 |
90 // Opens "file_in" (a .jar file) for reading, and writes an interface | 90 // Opens "file_in" (a .jar file) for reading, and writes an interface |
91 // .jar to "file_out". | 91 // .jar to "file_out". |
92 void OpenFilesAndProcessJar(const char *file_out, const char *file_in) { | 92 void OpenFilesAndProcessJar(const char *file_out, const char *file_in) { |
93 JarStripperProcessor processor; | 93 JarStripperProcessor processor; |
94 std::unique_ptr<ZipExtractor> in(ZipExtractor::Create(file_in, &processor)); | 94 std::unique_ptr<ZipExtractor> in(ZipExtractor::Create(file_in, &processor)); |
95 if (in.get() == NULL) { | 95 if (in.get() == NULL) { |
96 fprintf(stderr, "Unable to open Zip file %s: %s\n", file_in, | 96 fprintf(stderr, "Unable to open Zip file %s: %s\n", file_in, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 if (devtools_ijar::verbose) { | 180 if (devtools_ijar::verbose) { |
181 fprintf(stderr, "INFO: writing to '%s'.\n", filename_out); | 181 fprintf(stderr, "INFO: writing to '%s'.\n", filename_out); |
182 } | 182 } |
183 | 183 |
184 devtools_ijar::OpenFilesAndProcessJar(filename_out, filename_in); | 184 devtools_ijar::OpenFilesAndProcessJar(filename_out, filename_in); |
185 return 0; | 185 return 0; |
186 } | 186 } |
OLD | NEW |