ファイルの読み込み

諏訪子 <suwako@076.moe>、2026-05-04 22:58
コミット c73caa1867f5ec6f04cc7aa265f874ebdae6ea8c ・親 9398075 ・ファイルを見る

3個のファイル、+51 -0

追加 LICENSE.md
@@ -0,0 +1,21 @@
1+# 076 Free License
2+
3+Copyright (c) テクニカル諏訪子
4+
5+Permission is hereby granted to any person obtaining a copy of the software
6+LibJpeg (the "Software") to use, modify, merge, copy, publish, distribute,
7+sublicense, and/or sell copies of the Software, subject to the following conditions:
8+
9+ 1. **Origin Attribution**:
10+ - You must not misrepresent the origin of the Software; you must not claim
11+ you created the original Software.
12+ 2. **Notice Preservation**:
13+ - This license and the above copyright notice must remain intact in all copies
14+ of the source code.
15+
16+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
追加 file.cc
@@ -0,0 +1,22 @@
1+#include "file.hh"
2+
3+#include <iostream>
4+#include <fstream>
5+
6+vector<u8> read_file(const string &filename) {
7+ std::ifstream file(filename, std::ios::binary | std::ios::ate);
8+ if (!file) {
9+
10+ }
11+
12+ const auto size = file.tellg();
13+ file.seekg(0);
14+ vector<u8> data(static_cast<size_t>(size));
15+ if (!file.read(reinterpret_cast<char *>(data.data()), size)) {
16+
17+ }
18+
19+ file.close();
20+
21+ return data;
22+}
追加 file.hh
@@ -0,0 +1,8 @@
1+#ifndef FILE_HH
2+#define FILE_HH
3+
4+#include "types.hh"
5+
6+vector<u8> read_file(const string &filename);
7+
8+#endif // FILE_HH