OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "nacl_io/html5fs/html5_fs_node.h" | 5 #include "nacl_io/html5fs/html5_fs_node.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <ppapi/c/pp_completion_callback.h> | 9 #include <ppapi/c/pp_completion_callback.h> |
10 #include <ppapi/c/pp_directory_entry.h> | 10 #include <ppapi/c/pp_directory_entry.h> |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 var_iface_ = filesystem_->ppapi()->GetVarInterface(); | 261 var_iface_ = filesystem_->ppapi()->GetVarInterface(); |
262 | 262 |
263 if (!(file_io_iface_ && file_ref_iface_ && var_iface_)) { | 263 if (!(file_io_iface_ && file_ref_iface_ && var_iface_)) { |
264 LOG_ERROR("Got NULL interface(s): %s%s%s", | 264 LOG_ERROR("Got NULL interface(s): %s%s%s", |
265 file_ref_iface_ ? "" : "FileRef", | 265 file_ref_iface_ ? "" : "FileRef", |
266 file_io_iface_ ? "" : "FileIo ", | 266 file_io_iface_ ? "" : "FileIo ", |
267 var_iface_ ? "" : "Var "); | 267 var_iface_ ? "" : "Var "); |
268 return EIO; | 268 return EIO; |
269 } | 269 } |
270 | 270 |
| 271 // Set all files and directories to RWX. |
| 272 SetMode(S_IWALL | S_IRALL | S_IXALL); |
| 273 |
271 // First query the FileRef to see if it is a file or directory. | 274 // First query the FileRef to see if it is a file or directory. |
272 PP_FileInfo file_info; | 275 PP_FileInfo file_info; |
273 int32_t query_result = file_ref_iface_->Query( | 276 int32_t query_result = file_ref_iface_->Query( |
274 fileref_resource_, &file_info, PP_BlockUntilComplete()); | 277 fileref_resource_, &file_info, PP_BlockUntilComplete()); |
275 // If this is a directory, do not get a FileIO. | 278 // If this is a directory, do not get a FileIO. |
276 if (query_result == PP_OK && file_info.type == PP_FILETYPE_DIRECTORY) | 279 if (query_result == PP_OK && file_info.type == PP_FILETYPE_DIRECTORY) { |
277 return 0; | 280 return 0; |
| 281 } |
278 | 282 |
279 fileio_resource_ = | 283 fileio_resource_ = |
280 file_io_iface_->Create(filesystem_->ppapi()->GetInstance()); | 284 file_io_iface_->Create(filesystem_->ppapi()->GetInstance()); |
281 if (!fileio_resource_) { | 285 if (!fileio_resource_) { |
282 LOG_ERROR("Couldn't create FileIo resource."); | 286 LOG_ERROR("Couldn't create FileIo resource."); |
283 return EIO; | 287 return EIO; |
284 } | 288 } |
285 | 289 |
286 int32_t open_result = | 290 int32_t open_result = |
287 file_io_iface_->Open(fileio_resource_, | 291 file_io_iface_->Open(fileio_resource_, |
(...skipping 13 matching lines...) Expand all Loading... |
301 filesystem_->ppapi()->ReleaseResource(fileio_resource_); | 305 filesystem_->ppapi()->ReleaseResource(fileio_resource_); |
302 } | 306 } |
303 | 307 |
304 filesystem_->ppapi()->ReleaseResource(fileref_resource_); | 308 filesystem_->ppapi()->ReleaseResource(fileref_resource_); |
305 fileio_resource_ = 0; | 309 fileio_resource_ = 0; |
306 fileref_resource_ = 0; | 310 fileref_resource_ = 0; |
307 Node::Destroy(); | 311 Node::Destroy(); |
308 } | 312 } |
309 | 313 |
310 } // namespace nacl_io | 314 } // namespace nacl_io |
OLD | NEW |