OLD | NEW |
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 "webkit/glue/webfileutilities_impl.h" | 5 #include "webkit/glue/webfileutilities_impl.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return webkit_base::FilePathStringToWebString(combined_path.value()); | 71 return webkit_base::FilePathStringToWebString(combined_path.value()); |
72 } | 72 } |
73 | 73 |
74 bool WebFileUtilitiesImpl::makeAllDirectories(const WebString& path) { | 74 bool WebFileUtilitiesImpl::makeAllDirectories(const WebString& path) { |
75 DCHECK(!sandbox_enabled_); | 75 DCHECK(!sandbox_enabled_); |
76 base::FilePath file_path = webkit_base::WebStringToFilePath(path); | 76 base::FilePath file_path = webkit_base::WebStringToFilePath(path); |
77 return file_util::CreateDirectory(file_path); | 77 return file_util::CreateDirectory(file_path); |
78 } | 78 } |
79 | 79 |
80 WebString WebFileUtilitiesImpl::getAbsolutePath(const WebString& path) { | 80 WebString WebFileUtilitiesImpl::getAbsolutePath(const WebString& path) { |
81 base::FilePath file_path(webkit_base::WebStringToFilePath(path)); | 81 base::FilePath file_path(webkit_base::WebStringToFilePath(path).AsAbsolute()); |
82 file_util::AbsolutePath(&file_path); | |
83 return webkit_base::FilePathStringToWebString(file_path.value()); | 82 return webkit_base::FilePathStringToWebString(file_path.value()); |
84 } | 83 } |
85 | 84 |
86 bool WebFileUtilitiesImpl::isDirectory(const WebString& path) { | 85 bool WebFileUtilitiesImpl::isDirectory(const WebString& path) { |
87 base::FilePath file_path(webkit_base::WebStringToFilePath(path)); | 86 base::FilePath file_path(webkit_base::WebStringToFilePath(path)); |
88 return file_util::DirectoryExists(file_path); | 87 return file_util::DirectoryExists(file_path); |
89 } | 88 } |
90 | 89 |
91 WebKit::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { | 90 WebKit::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { |
92 return net::FilePathToFileURL(webkit_base::WebStringToFilePath(path)); | 91 return net::FilePathToFileURL(webkit_base::WebStringToFilePath(path)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 139 |
141 int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, | 140 int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, |
142 const char* data, | 141 const char* data, |
143 int length) { | 142 int length) { |
144 if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) | 143 if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) |
145 return -1; | 144 return -1; |
146 return base::WritePlatformFileCurPosNoBestEffort(handle, data, length); | 145 return base::WritePlatformFileCurPosNoBestEffort(handle, data, length); |
147 } | 146 } |
148 | 147 |
149 } // namespace webkit_glue | 148 } // namespace webkit_glue |
OLD | NEW |