Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 3169725

Browse files
committed
修复: 上传图片未检查文件是否成功打开;
1 parent a94554c commit 3169725

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/mirai_bot.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ namespace Cyan
868868
string MiraiBot::ReadFile(const string& filename)
869869
{
870870
std::ifstream ifs(filename, std::ifstream::binary);
871+
if (!ifs.is_open()) throw std::runtime_error("打开文件失败,请确认路径是否正确并检查文件是否存在");
871872
std::filebuf* pbuf = ifs.rdbuf();
872873
std::size_t size = pbuf->pubseekoff(0, ifs.end, ifs.in);
873874
pbuf->pubseekpos(0, ifs.in);

0 commit comments

Comments
 (0)