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

Side by Side Diff: net/disk_cache/os_file_win.cc

Issue 8843: Add write and read/write support to FileStream (renamed from FileInputStream)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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/disk_cache/os_file_posix.cc ('k') | net/net.xcodeproj/project.pbxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/disk_cache/os_file.h"
6
7 #include "base/logging.h"
8
9 namespace disk_cache {
10
11 OSFile CreateOSFile(const std::wstring& name, int flags, bool* created) {
12 DWORD disposition = 0;
13
14 if (flags & OS_FILE_OPEN)
15 disposition = OPEN_EXISTING;
16
17 if (flags & OS_FILE_CREATE) {
18 DCHECK(!disposition);
19 disposition = CREATE_NEW;
20 }
21
22 if (flags & OS_FILE_OPEN_ALWAYS) {
23 DCHECK(!disposition);
24 disposition = OPEN_ALWAYS;
25 }
26
27 if (flags & OS_FILE_CREATE_ALWAYS) {
28 DCHECK(!disposition);
29 disposition = CREATE_ALWAYS;
30 }
31
32 if (!disposition) {
33 NOTREACHED();
34 return NULL;
35 }
36
37 DWORD access = (flags & OS_FILE_READ) ? GENERIC_READ : 0;
38 if (flags & OS_FILE_WRITE)
39 access |= GENERIC_WRITE;
40
41 DWORD sharing = (flags & OS_FILE_SHARE_READ) ? FILE_SHARE_READ : 0;
42 if (flags & OS_FILE_SHARE_WRITE)
43 access |= FILE_SHARE_WRITE;
44
45 HANDLE file = CreateFile(name.c_str(), access, sharing, NULL, disposition, 0,
46 NULL);
47
48 if ((flags & OS_FILE_OPEN_ALWAYS) && created &&
49 INVALID_HANDLE_VALUE != file) {
50 *created = (ERROR_ALREADY_EXISTS != GetLastError());
51 }
52
53 return file;
54 }
55
56 } // namespace disk_cache
57
OLDNEW
« no previous file with comments | « net/disk_cache/os_file_posix.cc ('k') | net/net.xcodeproj/project.pbxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698