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 #include "base/files/file.h" | 5 #include "base/files/file.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 464 } |
465 | 465 |
466 // Static. | 466 // Static. |
467 File::Error File::OSErrorToFileError(int saved_errno) { | 467 File::Error File::OSErrorToFileError(int saved_errno) { |
468 switch (saved_errno) { | 468 switch (saved_errno) { |
469 case EACCES: | 469 case EACCES: |
470 case EISDIR: | 470 case EISDIR: |
471 case EROFS: | 471 case EROFS: |
472 case EPERM: | 472 case EPERM: |
473 return FILE_ERROR_ACCESS_DENIED; | 473 return FILE_ERROR_ACCESS_DENIED; |
| 474 case EBUSY: |
474 #if !defined(OS_NACL) // ETXTBSY not defined by NaCl. | 475 #if !defined(OS_NACL) // ETXTBSY not defined by NaCl. |
475 case ETXTBSY: | 476 case ETXTBSY: |
| 477 #endif |
476 return FILE_ERROR_IN_USE; | 478 return FILE_ERROR_IN_USE; |
477 #endif | |
478 case EEXIST: | 479 case EEXIST: |
479 return FILE_ERROR_EXISTS; | 480 return FILE_ERROR_EXISTS; |
| 481 case EIO: |
| 482 return FILE_ERROR_IO; |
480 case ENOENT: | 483 case ENOENT: |
481 return FILE_ERROR_NOT_FOUND; | 484 return FILE_ERROR_NOT_FOUND; |
482 case EMFILE: | 485 case EMFILE: |
483 return FILE_ERROR_TOO_MANY_OPENED; | 486 return FILE_ERROR_TOO_MANY_OPENED; |
484 case ENOMEM: | 487 case ENOMEM: |
485 return FILE_ERROR_NO_MEMORY; | 488 return FILE_ERROR_NO_MEMORY; |
486 case ENOSPC: | 489 case ENOSPC: |
487 return FILE_ERROR_NO_SPACE; | 490 return FILE_ERROR_NO_SPACE; |
488 case ENOTDIR: | 491 case ENOTDIR: |
489 return FILE_ERROR_NOT_A_DIRECTORY; | 492 return FILE_ERROR_NOT_A_DIRECTORY; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 543 } |
541 | 544 |
542 void File::SetPlatformFile(PlatformFile file) { | 545 void File::SetPlatformFile(PlatformFile file) { |
543 CHECK(!file_.is_valid()); | 546 CHECK(!file_.is_valid()); |
544 file_.reset(file); | 547 file_.reset(file); |
545 if (file_.is_valid()) | 548 if (file_.is_valid()) |
546 ProtectFileDescriptor(GetPlatformFile()); | 549 ProtectFileDescriptor(GetPlatformFile()); |
547 } | 550 } |
548 | 551 |
549 } // namespace base | 552 } // namespace base |
OLD | NEW |