| 1407 | } |
| 1408 | |
| 1409 | bool gguf_write_to_file(const struct gguf_context * ctx, const char * fname, bool only_meta) { |
| 1410 | FILE * file = ggml_fopen(fname, "wb"); |
| 1411 | |
| 1412 | if (!file) { |
| 1413 | GGML_LOG_ERROR("%s: failed to open file '%s' for writing GGUF data\n", __func__, fname); |
| 1414 | return false; |
| 1415 | } |
| 1416 | |
| 1417 | try { |
| 1418 | gguf_writer_file gw(file); |
| 1419 | gguf_write_out(ctx, gw, only_meta); |
| 1420 | } catch (const std::runtime_error& ex) { |
| 1421 | GGML_LOG_ERROR("%s: failed to write GGUF data into '%s': %s\n", __func__, fname, ex.what()); |
| 1422 | fclose(file); |
| 1423 | return false; |
| 1424 | } |
| 1425 | |
| 1426 | fclose(file); |
| 1427 | return true; |
| 1428 | } |
| 1429 | |
| 1430 | size_t gguf_get_meta_size(const struct gguf_context * ctx) { |
| 1431 | // only return size |
no test coverage detected