| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // Some common file utilities for plugin code. | 5 // Some common file utilities for plugin code. |
| 6 | 6 |
| 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_UTILS_H_ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_UTILS_H_ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_UTILS_H_ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_UTILS_H_ |
| 9 | 9 |
| 10 #include "native_client/src/include/nacl_string.h" | 10 #include "native_client/src/include/nacl_string.h" |
| 11 #include "native_client/src/include/portability_io.h" | 11 #include "native_client/src/include/portability_io.h" |
| 12 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
| 13 #include "ppapi/c/private/pp_file_handle.h" |
| 13 | 14 |
| 14 namespace plugin { | 15 namespace plugin { |
| 15 namespace file_utils { | 16 namespace file_utils { |
| 16 | 17 |
| 17 enum StatusCode { | 18 enum StatusCode { |
| 18 PLUGIN_FILE_SUCCESS = 0, | 19 PLUGIN_FILE_SUCCESS = 0, |
| 19 PLUGIN_FILE_ERROR_MEM_ALLOC = 1, | 20 PLUGIN_FILE_ERROR_MEM_ALLOC = 1, |
| 20 PLUGIN_FILE_ERROR_OPEN = 2, | 21 PLUGIN_FILE_ERROR_OPEN = 2, |
| 21 PLUGIN_FILE_ERROR_FILE_TOO_LARGE = 3, | 22 PLUGIN_FILE_ERROR_FILE_TOO_LARGE = 3, |
| 22 PLUGIN_FILE_ERROR_STAT = 4, | 23 PLUGIN_FILE_ERROR_STAT = 4, |
| 23 PLUGIN_FILE_ERROR_READ = 5 | 24 PLUGIN_FILE_ERROR_READ = 5 |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 // Slurp the whole contents of the given file (|fd| - open file descriptor) into | 27 // Slurp the whole contents of the given file (|fd| - open file descriptor) into |
| 27 // |out_buf|. |max_size_to_read| is the maximal allowed size of the file. | 28 // |out_buf|. |max_size_to_read| is the maximal allowed size of the file. |
| 28 // If the file turns out to be larger, an error is returned. In any case, | 29 // If the file turns out to be larger, an error is returned. In any case, |
| 29 // |fd| is closed. | 30 // |fd| is closed. |
| 30 StatusCode SlurpFile(int32_t fd, | 31 StatusCode SlurpFile(int32_t fd, |
| 31 nacl::string& out_buf, | 32 nacl::string& out_buf, |
| 32 size_t max_size_to_read = (1 << 20)); | 33 size_t max_size_to_read = (1 << 20)); |
| 33 | 34 |
| 35 int32_t ConvertFileDescriptor(PP_FileHandle handle); |
| 36 |
| 34 } // namespace file_utils | 37 } // namespace file_utils |
| 35 } // namespace plugin | 38 } // namespace plugin |
| 36 | 39 |
| 37 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_UTILS_H_ | 40 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_UTILS_H_ |
| 38 | |
| OLD | NEW |