]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
main : allow empty --prompt-cache file (#5176)
authordivinity76 <redacted>
Tue, 30 Jan 2024 09:18:02 +0000 (10:18 +0100)
committerGitHub <redacted>
Tue, 30 Jan 2024 09:18:02 +0000 (11:18 +0200)
commit813416991ab0d1caa0d12f93ac4e8a24a2add0a3
tree2fcb1475703a7f01b4cc85281146321d924896e0
parent5589921ef84a4fb1c6d1c9c34d626a5a83033db6
main : allow empty --prompt-cache file (#5176)

* allow empty --prompt-cache file

This allows the use of std::tmpnam(), std::tmpfile(), Python's tempfile.NamedTemporaryFile(), and similar create-empty-file API's for the user.

I switched from the C fopen API to the C++ filesystem api to get around the fact that, to the best of my knowledge, C has no portable way to get the file size above LONG_MAX, with std::ftell() returning long? fallback to std::ifstream for c++  < 17
(the project is currently targeting C++11 it seems - file_exists() and file_size() can be removed when we upgrade to c++17)

* formatting

(requested in codereview)

* remove c++17, file_is_empty
examples/main/main.cpp