| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/tests/test_flash_file.h" | 5 #include "ppapi/tests/test_flash_file.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/c/pp_file_info.h" | 10 #include "ppapi/c/pp_file_info.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #if defined(PPAPI_OS_WIN) | 29 #if defined(PPAPI_OS_WIN) |
| 30 CloseHandle(file_handle); | 30 CloseHandle(file_handle); |
| 31 #else | 31 #else |
| 32 close(file_handle); | 32 close(file_handle); |
| 33 #endif | 33 #endif |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool WriteFile(PP_FileHandle file_handle, const std::string& contents) { | 36 bool WriteFile(PP_FileHandle file_handle, const std::string& contents) { |
| 37 #if defined(PPAPI_OS_WIN) | 37 #if defined(PPAPI_OS_WIN) |
| 38 DWORD bytes_written = 0; | 38 DWORD bytes_written = 0; |
| 39 BOOL result = ::WriteFile(file_handle, contents.c_str(), contents.size(), | 39 BOOL result = ::WriteFile(file_handle, contents.c_str(), |
| 40 static_cast<DWORD>(contents.size()), |
| 40 &bytes_written, NULL); | 41 &bytes_written, NULL); |
| 41 return result && bytes_written == static_cast<DWORD>(contents.size()); | 42 return result && bytes_written == static_cast<DWORD>(contents.size()); |
| 42 #else | 43 #else |
| 43 ssize_t bytes_written = 0; | 44 ssize_t bytes_written = 0; |
| 44 do { | 45 do { |
| 45 bytes_written = write(file_handle, contents.c_str(), contents.size()); | 46 bytes_written = write(file_handle, contents.c_str(), contents.size()); |
| 46 } while (bytes_written == -1 && errno == EINTR); | 47 } while (bytes_written == -1 && errno == EINTR); |
| 47 return bytes_written == static_cast<ssize_t>(contents.size()); | 48 return bytes_written == static_cast<ssize_t>(contents.size()); |
| 48 #endif | 49 #endif |
| 49 } | 50 } |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 326 } |
| 326 | 327 |
| 327 std::string TestFlashFile::GetItemCountUnderModuleLocalRoot( | 328 std::string TestFlashFile::GetItemCountUnderModuleLocalRoot( |
| 328 size_t* item_count) { | 329 size_t* item_count) { |
| 329 std::vector<FileModuleLocal::DirEntry> contents; | 330 std::vector<FileModuleLocal::DirEntry> contents; |
| 330 ASSERT_TRUE( | 331 ASSERT_TRUE( |
| 331 FileModuleLocal::GetDirContents(instance_, std::string(), &contents)); | 332 FileModuleLocal::GetDirContents(instance_, std::string(), &contents)); |
| 332 *item_count = contents.size(); | 333 *item_count = contents.size(); |
| 333 PASS(); | 334 PASS(); |
| 334 } | 335 } |
| OLD | NEW |