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/httpfs/http_fs.h" | 5 #include "nacl_io/httpfs/http_fs.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <ctype.h> | 8 #include <ctype.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // Ignore EXEC bit | 314 // Ignore EXEC bit |
315 int mode = S_IFREG; | 315 int mode = S_IFREG; |
316 switch (modestr[0]) { | 316 switch (modestr[0]) { |
317 case '-': | 317 case '-': |
318 mode = S_IFREG; | 318 mode = S_IFREG; |
319 break; | 319 break; |
320 case 'c': | 320 case 'c': |
321 mode = S_IFCHR; | 321 mode = S_IFCHR; |
322 break; | 322 break; |
323 default: | 323 default: |
324 LOG_ERROR("Unable to parse type %s for %s.\n", | 324 LOG_ERROR("Unable to parse type %s for %s.", |
325 modestr.c_str(), | 325 modestr.c_str(), |
326 name.c_str()); | 326 name.c_str()); |
327 return EINVAL; | 327 return EINVAL; |
328 } | 328 } |
329 | 329 |
330 switch (modestr[1]) { | 330 switch (modestr[1]) { |
331 case '-': | 331 case '-': |
332 break; | 332 break; |
333 case 'r': | 333 case 'r': |
334 mode |= S_IRUSR | S_IRGRP | S_IROTH; | 334 mode |= S_IRUSR | S_IRGRP | S_IROTH; |
335 break; | 335 break; |
336 default: | 336 default: |
337 LOG_ERROR("Unable to parse read %s for %s.\n", | 337 LOG_ERROR("Unable to parse read %s for %s.", |
338 modestr.c_str(), | 338 modestr.c_str(), |
339 name.c_str()); | 339 name.c_str()); |
340 return EINVAL; | 340 return EINVAL; |
341 } | 341 } |
342 | 342 |
343 switch (modestr[2]) { | 343 switch (modestr[2]) { |
344 case '-': | 344 case '-': |
345 break; | 345 break; |
346 case 'w': | 346 case 'w': |
347 mode |= S_IWUSR | S_IWGRP | S_IWOTH; | 347 mode |= S_IWUSR | S_IWGRP | S_IWOTH; |
348 break; | 348 break; |
349 default: | 349 default: |
350 LOG_ERROR("Unable to parse write %s for %s.\n", | 350 LOG_ERROR("Unable to parse write %s for %s.", |
351 modestr.c_str(), | 351 modestr.c_str(), |
352 name.c_str()); | 352 name.c_str()); |
353 return EINVAL; | 353 return EINVAL; |
354 } | 354 } |
355 | 355 |
356 Path path(name); | 356 Path path(name); |
357 std::string url = MakeUrl(path); | 357 std::string url = MakeUrl(path); |
358 | 358 |
359 HttpFsNode* http_node = new HttpFsNode(this, url, cache_content_); | 359 HttpFsNode* http_node = new HttpFsNode(this, url, cache_content_); |
360 http_node->SetMode(mode); | 360 http_node->SetMode(mode); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 *out_manifest = text; | 407 *out_manifest = text; |
408 return 0; | 408 return 0; |
409 } | 409 } |
410 | 410 |
411 std::string HttpFs::MakeUrl(const Path& path) { | 411 std::string HttpFs::MakeUrl(const Path& path) { |
412 return url_root_ + | 412 return url_root_ + |
413 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); | 413 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); |
414 } | 414 } |
415 | 415 |
416 } // namespace nacl_io | 416 } // namespace nacl_io |
OLD | NEW |