Chromium Code Reviews| Index: native_client_sdk/src/libraries/nacl_io/mount_http.cc |
| diff --git a/native_client_sdk/src/libraries/nacl_io/mount_http.cc b/native_client_sdk/src/libraries/nacl_io/mount_http.cc |
| index 15c32e623106b3b3132a28038bce3b11652b5b49..5aa06b07b956292a60ec503c371a302fe0af4c6b 100644 |
| --- a/native_client_sdk/src/libraries/nacl_io/mount_http.cc |
| +++ b/native_client_sdk/src/libraries/nacl_io/mount_http.cc |
| @@ -13,6 +13,7 @@ |
| #include <string.h> |
| #include <sys/stat.h> |
| #include <sys/types.h> |
| +#include <unistd.h> |
| #include <vector> |
| @@ -54,6 +55,37 @@ std::string NormalizeHeaderKey(const std::string& s) { |
| return result; |
| } |
| +Error MountHttp::Access(const Path& path, int a_mode) { |
| + assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/'); |
| + |
| + NodeMap_t::iterator iter = node_cache_.find(path.Join()); |
| + if (iter == node_cache_.end()) { |
| + // If we can't find the node in the cache, fetch it |
| + std::string url = url_root_ + |
|
binji
2013/06/19 16:46:28
might be nice to refactor this into a MakeURL func
Matt Giuca
2013/06/20 01:43:14
Done.
|
| + (path.IsAbsolute() ? path.Range(1, path.Size()) |
| + : path.Join()); |
| + |
| + MountNodeHttp* node = new MountNodeHttp(this, url, cache_content_); |
| + Error error = node->Init(O_RDONLY); |
| + if (error) { |
| + node->Release(); |
| + return error; |
| + } |
| + |
| + error = node->GetStat(NULL); |
| + if (error) { |
| + node->Release(); |
| + return error; |
| + } |
|
binji
2013/06/19 16:46:28
release the node here
Matt Giuca
2013/06/20 01:43:14
Done.
|
| + } |
| + |
| + // Don't allow write or execute access. |
| + if (a_mode & (W_OK | X_OK)) |
| + return EACCES; |
| + |
| + return 0; |
| +} |
| + |
| Error MountHttp::Open(const Path& path, int mode, MountNode** out_node) { |
| *out_node = NULL; |