Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: net/base/file_stream_posix.cc

Issue 18764: Change FileStream to use FilePath instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 // For 64-bit file access (off_t = off64_t, lseek64, etc). 5 // For 64-bit file access (off_t = off64_t, lseek64, etc).
6 #define _FILE_OFFSET_BITS 64 6 #define _FILE_OFFSET_BITS 64
7 7
8 #include "net/base/file_stream.h" 8 #include "net/base/file_stream.h"
9 9
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 case ENOENT: 67 case ENOENT:
68 return ERR_FILE_NOT_FOUND; 68 return ERR_FILE_NOT_FOUND;
69 case EACCES: 69 case EACCES:
70 return ERR_ACCESS_DENIED; 70 return ERR_ACCESS_DENIED;
71 default: 71 default:
72 LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED"; 72 LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED";
73 return ERR_FAILED; 73 return ERR_FAILED;
74 } 74 }
75 } 75 }
76 76
77 int FileStream::Open(const std::wstring& path, int open_flags) { 77 int FileStream::Open(const FilePath& path, int open_flags) {
78 if (IsOpen()) { 78 if (IsOpen()) {
79 DLOG(FATAL) << "File is already open!"; 79 DLOG(FATAL) << "File is already open!";
80 return ERR_UNEXPECTED; 80 return ERR_UNEXPECTED;
81 } 81 }
82 82
83 open_flags_ = open_flags; 83 open_flags_ = open_flags;
84 file_ = base::CreatePlatformFile(path, open_flags_, NULL); 84 file_ = base::CreatePlatformFile(path.ToWStringHack(), open_flags_, NULL);
85 if (file_ == base::kInvalidPlatformFileValue) { 85 if (file_ == base::kInvalidPlatformFileValue) {
86 LOG(WARNING) << "Failed to open file: " << errno; 86 LOG(WARNING) << "Failed to open file: " << errno;
87 return MapErrorCode(errno); 87 return MapErrorCode(errno);
88 } 88 }
89 89
90 return OK; 90 return OK;
91 } 91 }
92 92
93 bool FileStream::IsOpen() const { 93 bool FileStream::IsOpen() const {
94 return file_ != base::kInvalidPlatformFileValue; 94 return file_ != base::kInvalidPlatformFileValue;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return MapErrorCode(errno); 168 return MapErrorCode(errno);
169 } 169 }
170 total_bytes_written += res; 170 total_bytes_written += res;
171 buf += res; 171 buf += res;
172 len -= res; 172 len -= res;
173 } 173 }
174 return total_bytes_written; 174 return total_bytes_written;
175 } 175 }
176 176
177 } // namespace net 177 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698