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

Side by Side Diff: base/json/json_file_value_serializer.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/files/important_file_writer_unittest.cc ('k') | base/json/json_reader_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) 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/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 DCHECK(json_string); 48 DCHECK(json_string);
49 if (!file_util::ReadFileToString(json_file_path_, json_string)) { 49 if (!file_util::ReadFileToString(json_file_path_, json_string)) {
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 int error = ::GetLastError(); 51 int error = ::GetLastError();
52 if (error == ERROR_SHARING_VIOLATION || error == ERROR_LOCK_VIOLATION) { 52 if (error == ERROR_SHARING_VIOLATION || error == ERROR_LOCK_VIOLATION) {
53 return JSON_FILE_LOCKED; 53 return JSON_FILE_LOCKED;
54 } else if (error == ERROR_ACCESS_DENIED) { 54 } else if (error == ERROR_ACCESS_DENIED) {
55 return JSON_ACCESS_DENIED; 55 return JSON_ACCESS_DENIED;
56 } 56 }
57 #endif 57 #endif
58 if (!file_util::PathExists(json_file_path_)) 58 if (!base::PathExists(json_file_path_))
59 return JSON_NO_SUCH_FILE; 59 return JSON_NO_SUCH_FILE;
60 else 60 else
61 return JSON_CANNOT_READ_FILE; 61 return JSON_CANNOT_READ_FILE;
62 } 62 }
63 return JSON_NO_ERROR; 63 return JSON_NO_ERROR;
64 } 64 }
65 65
66 const char* JSONFileValueSerializer::GetErrorMessageForCode(int error_code) { 66 const char* JSONFileValueSerializer::GetErrorMessageForCode(int error_code) {
67 switch (error_code) { 67 switch (error_code) {
68 case JSON_NO_ERROR: 68 case JSON_NO_ERROR:
(...skipping 21 matching lines...) Expand all
90 *error_code = error; 90 *error_code = error;
91 if (error_str) 91 if (error_str)
92 *error_str = GetErrorMessageForCode(error); 92 *error_str = GetErrorMessageForCode(error);
93 return NULL; 93 return NULL;
94 } 94 }
95 95
96 JSONStringValueSerializer serializer(json_string); 96 JSONStringValueSerializer serializer(json_string);
97 serializer.set_allow_trailing_comma(allow_trailing_comma_); 97 serializer.set_allow_trailing_comma(allow_trailing_comma_);
98 return serializer.Deserialize(error_code, error_str); 98 return serializer.Deserialize(error_code, error_str);
99 } 99 }
OLDNEW
« no previous file with comments | « base/files/important_file_writer_unittest.cc ('k') | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698