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

Side by Side Diff: base/platform_file_win.cc

Issue 3404018: Add a TouchFile function that operates on FilePaths + fixing a bug... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 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 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 "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 if (!disposition) { 42 if (!disposition) {
43 NOTREACHED(); 43 NOTREACHED();
44 return NULL; 44 return NULL;
45 } 45 }
46 46
47 DWORD access = (flags & PLATFORM_FILE_READ) ? GENERIC_READ : 0; 47 DWORD access = (flags & PLATFORM_FILE_READ) ? GENERIC_READ : 0;
48 if (flags & PLATFORM_FILE_WRITE) 48 if (flags & PLATFORM_FILE_WRITE)
49 access |= GENERIC_WRITE; 49 access |= GENERIC_WRITE;
50 if (flags & PLATFORM_FILE_WRITE_ATTRIBUTES)
51 access |= FILE_WRITE_ATTRIBUTES;
50 52
51 DWORD sharing = (flags & PLATFORM_FILE_EXCLUSIVE_READ) ? 0 : FILE_SHARE_READ; 53 DWORD sharing = (flags & PLATFORM_FILE_EXCLUSIVE_READ) ? 0 : FILE_SHARE_READ;
52 if (!(flags & PLATFORM_FILE_EXCLUSIVE_WRITE)) 54 if (!(flags & PLATFORM_FILE_EXCLUSIVE_WRITE))
53 sharing |= FILE_SHARE_WRITE; 55 sharing |= FILE_SHARE_WRITE;
54 56
55 DWORD create_flags = 0; 57 DWORD create_flags = 0;
56 if (flags & PLATFORM_FILE_ASYNC) 58 if (flags & PLATFORM_FILE_ASYNC)
57 create_flags |= FILE_FLAG_OVERLAPPED; 59 create_flags |= FILE_FLAG_OVERLAPPED;
58 if (flags & PLATFORM_FILE_TEMPORARY) 60 if (flags & PLATFORM_FILE_TEMPORARY)
59 create_flags |= FILE_ATTRIBUTE_TEMPORARY; 61 create_flags |= FILE_ATTRIBUTE_TEMPORARY;
60 if (flags & PLATFORM_FILE_HIDDEN) 62 if (flags & PLATFORM_FILE_HIDDEN)
61 create_flags |= FILE_ATTRIBUTE_HIDDEN; 63 create_flags |= FILE_ATTRIBUTE_HIDDEN;
62 if (flags & PLATFORM_FILE_DELETE_ON_CLOSE) 64 if (flags & PLATFORM_FILE_DELETE_ON_CLOSE)
63 create_flags |= FILE_FLAG_DELETE_ON_CLOSE; 65 create_flags |= FILE_FLAG_DELETE_ON_CLOSE;
64 if (flags & PLATFORM_FILE_WRITE_ATTRIBUTES)
65 create_flags |= FILE_WRITE_ATTRIBUTES;
66 66
67 HANDLE file = CreateFile(name.value().c_str(), access, sharing, NULL, 67 HANDLE file = CreateFile(name.value().c_str(), access, sharing, NULL,
68 disposition, create_flags, NULL); 68 disposition, create_flags, NULL);
69 69
70 if (created && (INVALID_HANDLE_VALUE != file)) { 70 if (created && (INVALID_HANDLE_VALUE != file)) {
71 if (flags & PLATFORM_FILE_OPEN_ALWAYS) 71 if (flags & PLATFORM_FILE_OPEN_ALWAYS)
72 *created = (ERROR_ALREADY_EXISTS != GetLastError()); 72 *created = (ERROR_ALREADY_EXISTS != GetLastError());
73 else if (flags & PLATFORM_FILE_CREATE_ALWAYS) 73 else if (flags & PLATFORM_FILE_CREATE_ALWAYS)
74 *created = true; 74 *created = true;
75 } 75 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 info->size = size.QuadPart; 204 info->size = size.QuadPart;
205 info->is_directory = 205 info->is_directory =
206 file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0; 206 file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0;
207 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); 207 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime);
208 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); 208 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime);
209 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); 209 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime);
210 return true; 210 return true;
211 } 211 }
212 212
213 } // namespace disk_cache 213 } // namespace disk_cache
OLDNEW
« no previous file with comments | « base/platform_file_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698