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

Side by Side Diff: base/platform_file_win.cc

Issue 319543004: Move and rename FdopenPlatformFile to file_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « base/platform_file_posix.cc ('k') | content/renderer/media/media_stream_audio_processor.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) 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/platform_file.h" 5 #include "base/platform_file.h"
6 6
7 #include <io.h> 7 #include <io.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/sparse_histogram.h" 11 #include "base/metrics/sparse_histogram.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 FILE* FdopenPlatformFile(PlatformFile file, const char* mode) {
17 if (file == kInvalidPlatformFileValue)
18 return NULL;
19 int fd = _open_osfhandle(reinterpret_cast<intptr_t>(file), 0);
20 if (fd < 0)
21 return NULL;
22 return _fdopen(fd, mode);
23 }
24
25 bool ClosePlatformFile(PlatformFile file) { 16 bool ClosePlatformFile(PlatformFile file) {
26 base::ThreadRestrictions::AssertIOAllowed(); 17 base::ThreadRestrictions::AssertIOAllowed();
27 return (CloseHandle(file) != 0); 18 return (CloseHandle(file) != 0);
28 } 19 }
29 20
30 int64 SeekPlatformFile(PlatformFile file, 21 int64 SeekPlatformFile(PlatformFile file,
31 PlatformFileWhence whence, 22 PlatformFileWhence whence,
32 int64 offset) { 23 int64 offset) {
33 base::ThreadRestrictions::AssertIOAllowed(); 24 base::ThreadRestrictions::AssertIOAllowed();
34 if (file == kInvalidPlatformFileValue || offset < 0) 25 if (file == kInvalidPlatformFileValue || offset < 0)
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 case ERROR_DISK_CORRUPT: 217 case ERROR_DISK_CORRUPT:
227 return PLATFORM_FILE_ERROR_IO; 218 return PLATFORM_FILE_ERROR_IO;
228 default: 219 default:
229 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Windows", 220 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Windows",
230 last_error); 221 last_error);
231 return PLATFORM_FILE_ERROR_FAILED; 222 return PLATFORM_FILE_ERROR_FAILED;
232 } 223 }
233 } 224 }
234 225
235 } // namespace base 226 } // namespace base
OLDNEW
« no previous file with comments | « base/platform_file_posix.cc ('k') | content/renderer/media/media_stream_audio_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698