ファイルの読み込み
This commit is contained in:
21
LICENSE.md
Executable file
21
LICENSE.md
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
# 076 Free License
|
||||||
|
|
||||||
|
Copyright (c) テクニカル諏訪子
|
||||||
|
|
||||||
|
Permission is hereby granted to any person obtaining a copy of the software
|
||||||
|
LibJpeg (the "Software") to use, modify, merge, copy, publish, distribute,
|
||||||
|
sublicense, and/or sell copies of the Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1. **Origin Attribution**:
|
||||||
|
- You must not misrepresent the origin of the Software; you must not claim
|
||||||
|
you created the original Software.
|
||||||
|
2. **Notice Preservation**:
|
||||||
|
- This license and the above copyright notice must remain intact in all copies
|
||||||
|
of the source code.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||||
|
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||||
|
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
22
file.cc
Executable file
22
file.cc
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "file.hh"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
vector<u8> read_file(const string &filename) {
|
||||||
|
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
||||||
|
if (!file) {
|
||||||
|
throw std::runtime_error("ファイルを開くに失敗: " + filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto size = file.tellg();
|
||||||
|
file.seekg(0);
|
||||||
|
vector<u8> data(static_cast<size_t>(size));
|
||||||
|
if (!file.read(reinterpret_cast<char *>(data.data()), size)) {
|
||||||
|
throw std::runtime_error("ファイルの読み込みに失敗。");
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user