| 26 | }; |
| 27 | |
| 28 | ZtringListList Load(const string& Name, const char* ToAdd = nullptr, bool IgnoreErrors = false) { |
| 29 | File InF(Ztring().From_Local(Name)); |
| 30 | auto InF_Size = InF.Size_Get(); |
| 31 | if (InF_Size > ((size_t)-1) / 2) |
| 32 | return {}; |
| 33 | auto Size = (size_t)InF_Size; |
| 34 | if (Size == 0) { |
| 35 | if (!IgnoreErrors) |
| 36 | std::cerr << "Can not open " << Name << '\n'; |
| 37 | return {}; |
| 38 | } |
| 39 | uint8_t* Buffer = new uint8_t[Size]; |
| 40 | if (InF.Read(Buffer, Size) != Size) { |
| 41 | if (!IgnoreErrors) |
| 42 | std::cerr << "Can not read " << Name << '\n'; |
| 43 | return {}; |
| 44 | } |
| 45 | Ztring In; |
| 46 | In.From_UTF8((const char*)Buffer, Size); |
| 47 | delete[] Buffer; |
| 48 | |
| 49 | if (ToAdd) { |
| 50 | In += Ztring().From_UTF8(ToAdd); |
| 51 | } |
| 52 | |
| 53 | ZtringListList List; |
| 54 | List.Write(In); |
| 55 | if (List.empty()) { |
| 56 | if (!IgnoreErrors) |
| 57 | std::cerr << "Can not extract " << Name << '\n'; |
| 58 | } |
| 59 | |
| 60 | return std::move(List); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | int main(int argc, char* argv[]) { |
no test coverage detected