| 89 | } |
| 90 | |
| 91 | int main(int argc, char** argv) { |
| 92 | int ind = 0; |
| 93 | if (argc < 4) { |
| 94 | Cerr << "usage: " << argv[ind] << "asm_output --prefix? [-? origin_resource ro_resource]+" << Endl; |
| 95 | return 1; |
| 96 | } |
| 97 | |
| 98 | TVector<TStringBuf> replacements; |
| 99 | |
| 100 | ind++; |
| 101 | |
| 102 | if (TStringBuf(argv[ind]) == "--compress-only") { |
| 103 | ind++; |
| 104 | while (ind + 1 < argc) { |
| 105 | TUnbufferedFileInput inp(argv[ind]); |
| 106 | TString data = inp.ReadAll(); |
| 107 | TString compressed = Compress(TStringBuf(data.data(), data.size())); |
| 108 | TFixedBufferFileOutput out(argv[ind+1]); |
| 109 | out << compressed; |
| 110 | ind += 2; |
| 111 | } |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | TFixedBufferFileOutput asmout(argv[ind]); |
| 116 | ind++; |
| 117 | TString prefix; |
| 118 | if (TStringBuf(argv[ind]) == "--prefix") { |
| 119 | prefix = "_"; |
| 120 | ind++; |
| 121 | } |
| 122 | else { |
| 123 | prefix = ""; |
| 124 | } |
| 125 | |
| 126 | while (TStringBuf(argv[ind]).StartsWith("--replace=")) { |
| 127 | replacements.push_back(TStringBuf(argv[ind]).SubStr(TStringBuf("--replace=").size())); |
| 128 | ind++; |
| 129 | } |
| 130 | |
| 131 | TAsmWriter aw(asmout, prefix); |
| 132 | bool raw; |
| 133 | bool error = false; |
| 134 | while (ind < argc) { |
| 135 | TString compressed; |
| 136 | if ("-"sv == argv[ind]) { |
| 137 | ind++; |
| 138 | if (ind >= argc) { |
| 139 | error = true; |
| 140 | break; |
| 141 | } |
| 142 | compressed = CompressPath(replacements, TStringBuf(argv[ind])); |
| 143 | raw = true; |
| 144 | } |
| 145 | else { |
| 146 | TUnbufferedFileInput inp(argv[ind]); |
| 147 | TString data = inp.ReadAll(); |
| 148 | compressed = Compress(TStringBuf(data.data(), data.size())); |
nothing calls this directly
no test coverage detected