| Index: base/platform_file_posix.cc
|
| diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
|
| index 7e6335e88451a090c54a6370f75b5a0122a6b8b3..f15870794b5a0ca964868a92bcbfa5aaa937b50c 100644
|
| --- a/base/platform_file_posix.cc
|
| +++ b/base/platform_file_posix.cc
|
| @@ -27,7 +27,7 @@ COMPILE_ASSERT(PLATFORM_FILE_FROM_BEGIN == SEEK_SET &&
|
| PLATFORM_FILE_FROM_CURRENT == SEEK_CUR &&
|
| PLATFORM_FILE_FROM_END == SEEK_END, whence_matches_system);
|
|
|
| -#if defined(OS_BSD) || defined(OS_MACOSX)
|
| +#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
|
| typedef struct stat stat_wrapper_t;
|
| static int CallFstat(int fd, stat_wrapper_t *sb) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -41,6 +41,9 @@ static int CallFstat(int fd, stat_wrapper_t *sb) {
|
| }
|
| #endif
|
|
|
| +// NaCl lacks many file handling system calls, so exclude any platform file
|
| +// functions that can't be implemented there.
|
| +#if !defined(OS_NACL)
|
| // TODO(erikkay): does it make sense to support PLATFORM_FILE_EXCLUSIVE_* here?
|
| PlatformFile CreatePlatformFileUnsafe(const FilePath& name,
|
| int flags,
|
| @@ -139,6 +142,7 @@ PlatformFile CreatePlatformFileUnsafe(const FilePath& name,
|
| FILE* FdopenPlatformFile(PlatformFile file, const char* mode) {
|
| return fdopen(file, mode);
|
| }
|
| +#endif // !defined(OS_NACL)
|
|
|
| bool ClosePlatformFile(PlatformFile file) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -155,6 +159,7 @@ int64 SeekPlatformFile(PlatformFile file,
|
| return lseek(file, static_cast<off_t>(offset), static_cast<int>(whence));
|
| }
|
|
|
| +#if !defined(OS_NACL) // NaCl has no pread.
|
| int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| if (file < 0 || size < 0)
|
| @@ -173,6 +178,7 @@ int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
|
|
|
| return bytes_read ? bytes_read : rv;
|
| }
|
| +#endif // !defined(OS_NACL)
|
|
|
| int ReadPlatformFileAtCurrentPos(PlatformFile file, char* data, int size) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -192,6 +198,7 @@ int ReadPlatformFileAtCurrentPos(PlatformFile file, char* data, int size) {
|
| return bytes_read ? bytes_read : rv;
|
| }
|
|
|
| +#if !defined(OS_NACL) // NaCl has no pread.
|
| int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset,
|
| char* data, int size) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -200,6 +207,7 @@ int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset,
|
|
|
| return HANDLE_EINTR(pread(file, data, size, offset));
|
| }
|
| +#endif // !defined(OS_NACL)
|
|
|
| int ReadPlatformFileCurPosNoBestEffort(PlatformFile file,
|
| char* data, int size) {
|
| @@ -210,6 +218,7 @@ int ReadPlatformFileCurPosNoBestEffort(PlatformFile file,
|
| return HANDLE_EINTR(read(file, data, size));
|
| }
|
|
|
| +#if !defined(OS_NACL) // NaCl has no fcntl or pwrite.
|
| int WritePlatformFile(PlatformFile file, int64 offset,
|
| const char* data, int size) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -233,6 +242,7 @@ int WritePlatformFile(PlatformFile file, int64 offset,
|
|
|
| return bytes_written ? bytes_written : rv;
|
| }
|
| +#endif // !defined(OS_NACL)
|
|
|
| int WritePlatformFileAtCurrentPos(PlatformFile file,
|
| const char* data, int size) {
|
| @@ -262,6 +272,7 @@ int WritePlatformFileCurPosNoBestEffort(PlatformFile file,
|
| return HANDLE_EINTR(write(file, data, size));
|
| }
|
|
|
| +#if !defined(OS_NACL) // NaCl has no ftruncate or fsync.
|
| bool TruncatePlatformFile(PlatformFile file, int64 length) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| return ((file >= 0) && !HANDLE_EINTR(ftruncate(file, length)));
|
| @@ -271,7 +282,9 @@ bool FlushPlatformFile(PlatformFile file) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| return !HANDLE_EINTR(fsync(file));
|
| }
|
| +#endif // !defined(OS_NACL)
|
|
|
| +#if !defined(OS_NACL)
|
| bool TouchPlatformFile(PlatformFile file, const base::Time& last_access_time,
|
| const base::Time& last_modified_time) {
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| @@ -297,6 +310,7 @@ bool TouchPlatformFile(PlatformFile file, const base::Time& last_access_time,
|
| return !futimes(file, times);
|
| #endif
|
| }
|
| +#endif // !defined(OS_NACL)
|
|
|
| bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) {
|
| if (!info)
|
| @@ -322,8 +336,10 @@ PlatformFileError ErrnoToPlatformFileError(int saved_errno) {
|
| case EROFS:
|
| case EPERM:
|
| return PLATFORM_FILE_ERROR_ACCESS_DENIED;
|
| +#if !defined(OS_NACL) // ETXTBSY not defined by NaCl.
|
| case ETXTBSY:
|
| return PLATFORM_FILE_ERROR_IN_USE;
|
| +#endif
|
| case EEXIST:
|
| return PLATFORM_FILE_ERROR_EXISTS;
|
| case ENOENT:
|
|
|