| 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 | 5 |
| 6 #include "nacl_mounts/mount_node_html5fs.h" | 6 #include "nacl_mounts/mount_node_html5fs.h" |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <ppapi/c/pp_completion_callback.h> | 10 #include <ppapi/c/pp_completion_callback.h> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 if (file_name_var.type != PP_VARTYPE_STRING) | 109 if (file_name_var.type != PP_VARTYPE_STRING) |
| 110 continue; | 110 continue; |
| 111 | 111 |
| 112 uint32_t file_name_length; | 112 uint32_t file_name_length; |
| 113 const char* file_name = mount_->ppapi()->GetVarInterface()->VarToUtf8( | 113 const char* file_name = mount_->ppapi()->GetVarInterface()->VarToUtf8( |
| 114 file_name_var, &file_name_length); | 114 file_name_var, &file_name_length); |
| 115 if (!file_name) | 115 if (!file_name) |
| 116 continue; | 116 continue; |
| 117 | 117 |
| 118 file_name_length = std::min( | 118 file_name_length = std::min( |
| 119 file_name_length, | 119 static_cast<size_t>(file_name_length), |
| 120 sizeof(static_cast<struct dirent*>(0)->d_name) - 1); // -1 for NULL. | 120 sizeof(static_cast<struct dirent*>(0)->d_name) - 1); // -1 for NULL. |
| 121 | 121 |
| 122 dirents.push_back(dirent()); | 122 dirents.push_back(dirent()); |
| 123 struct dirent& direntry = dirents.back(); | 123 struct dirent& direntry = dirents.back(); |
| 124 direntry.d_ino = 0; // TODO(binji): Is this needed? | 124 direntry.d_ino = 0; // TODO(binji): Is this needed? |
| 125 direntry.d_off = sizeof(struct dirent); | 125 direntry.d_off = sizeof(struct dirent); |
| 126 direntry.d_reclen = sizeof(struct dirent); | 126 direntry.d_reclen = sizeof(struct dirent); |
| 127 strncpy(direntry.d_name, file_name, file_name_length); | 127 strncpy(direntry.d_name, file_name, file_name_length); |
| 128 direntry.d_name[file_name_length] = 0; | 128 direntry.d_name[file_name_length] = 0; |
| 129 } | 129 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (fileio_resource_) { | 247 if (fileio_resource_) { |
| 248 mount_->ppapi()->GetFileIoInterface()->Close(fileio_resource_); | 248 mount_->ppapi()->GetFileIoInterface()->Close(fileio_resource_); |
| 249 mount_->ppapi()->ReleaseResource(fileio_resource_); | 249 mount_->ppapi()->ReleaseResource(fileio_resource_); |
| 250 } | 250 } |
| 251 | 251 |
| 252 mount_->ppapi()->ReleaseResource(fileref_resource_); | 252 mount_->ppapi()->ReleaseResource(fileref_resource_); |
| 253 fileio_resource_ = 0; | 253 fileio_resource_ = 0; |
| 254 fileref_resource_ = 0; | 254 fileref_resource_ = 0; |
| 255 return 0; | 255 return 0; |
| 256 } | 256 } |
| OLD | NEW |