OSDN Git Service

File::Write() を std::vector<std::uint8_t> 専用にし、Windows 7 でも動くように書き込んだバイト数を受け取るように修正
authorstarg <starg@users.osdn.me>
Sun, 4 Sep 2016 10:58:55 +0000 (19:58 +0900)
committerstarg <starg@users.osdn.me>
Sun, 4 Sep 2016 10:58:55 +0000 (19:58 +0900)
src/driver/file_win.cpp

index 892e0e7..fd394b0 100644 (file)
@@ -122,15 +122,16 @@ public:
         return ret;
     }
 
-    template<typename T>
-    void Write(const T& c)
+    void Write(const std::vector<std::uint8_t>& c)
     {
         if (!IsOpened())
         {
             throw std::logic_error("File is not opened yet.");
         }
 
-        if (!::WriteFile(m_hFile, c.data(), static_cast<DWORD>(c.size()), nullptr, nullptr))
+        DWORD bytesWritten;
+
+        if (!::WriteFile(m_hFile, c.data(), static_cast<DWORD>(c.size()), &bytesWritten, nullptr) || c.size() != bytesWritten)
         {
             throw IOException();
         }