| 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_path.h" |    7 #include "base/file_path.h" | 
|    8 #include "base/file_util.h" |    8 #include "base/file_util.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" | 
|   11 #include "net/base/net_util.h" |   11 #include "net/base/net_util.h" | 
|   12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |   12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 
|   13 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |   13 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 
|   14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" |   14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" | 
|   15 #include "webkit/base/file_path_string_conversions.h" |   15 #include "webkit/base/file_path_string_conversions.h" | 
|   16 #include "webkit/glue/webkit_glue.h" |   16 #include "webkit/glue/webkit_glue.h" | 
|   17  |   17  | 
|   18 using WebKit::WebString; |   18 using WebKit::WebString; | 
|   19  |   19  | 
|   20 namespace webkit_glue { |   20 namespace webkit_glue { | 
|   21  |   21  | 
|   22 WebFileUtilitiesImpl::WebFileUtilitiesImpl() |   22 WebFileUtilitiesImpl::WebFileUtilitiesImpl() | 
|   23     : sandbox_enabled_(true) { |   23     : sandbox_enabled_(true) { | 
|   24 } |   24 } | 
|   25  |   25  | 
|   26 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() { |   26 WebFileUtilitiesImpl::~WebFileUtilitiesImpl() { | 
|   27 } |   27 } | 
|   28  |   28  | 
|   29 bool WebFileUtilitiesImpl::fileExists(const WebString& path) { |   29 bool WebFileUtilitiesImpl::fileExists(const WebString& path) { | 
|   30   FilePath file_path = webkit_base::WebStringToFilePath(path); |   30   base::FilePath file_path = webkit_base::WebStringToFilePath(path); | 
|   31   return file_util::PathExists(file_path); |   31   return file_util::PathExists(file_path); | 
|   32 } |   32 } | 
|   33  |   33  | 
|   34 bool WebFileUtilitiesImpl::deleteFile(const WebString& path) { |   34 bool WebFileUtilitiesImpl::deleteFile(const WebString& path) { | 
|   35   NOTREACHED(); |   35   NOTREACHED(); | 
|   36   return false; |   36   return false; | 
|   37 } |   37 } | 
|   38  |   38  | 
|   39 bool WebFileUtilitiesImpl::deleteEmptyDirectory(const WebString& path) { |   39 bool WebFileUtilitiesImpl::deleteEmptyDirectory(const WebString& path) { | 
|   40   NOTREACHED(); |   40   NOTREACHED(); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|   51   if (!file_util::GetFileInfo(webkit_base::WebStringToFilePath(path), |   51   if (!file_util::GetFileInfo(webkit_base::WebStringToFilePath(path), | 
|   52                               &file_info)) |   52                               &file_info)) | 
|   53     return false; |   53     return false; | 
|   54  |   54  | 
|   55   webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); |   55   webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | 
|   56   web_file_info.platformPath = path; |   56   web_file_info.platformPath = path; | 
|   57   return true; |   57   return true; | 
|   58 } |   58 } | 
|   59  |   59  | 
|   60 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { |   60 WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { | 
|   61   FilePath file_path(webkit_base::WebStringToFilePath(path)); |   61   base::FilePath file_path(webkit_base::WebStringToFilePath(path)); | 
|   62   return webkit_base::FilePathToWebString(file_path.DirName()); |   62   return webkit_base::FilePathToWebString(file_path.DirName()); | 
|   63 } |   63 } | 
|   64  |   64  | 
|   65 WebString WebFileUtilitiesImpl::pathByAppendingComponent( |   65 WebString WebFileUtilitiesImpl::pathByAppendingComponent( | 
|   66     const WebString& webkit_path, |   66     const WebString& webkit_path, | 
|   67     const WebString& webkit_component) { |   67     const WebString& webkit_component) { | 
|   68   FilePath path(webkit_base::WebStringToFilePath(webkit_path)); |   68   base::FilePath path(webkit_base::WebStringToFilePath(webkit_path)); | 
|   69   FilePath component(webkit_base::WebStringToFilePath(webkit_component)); |   69   base::FilePath component(webkit_base::WebStringToFilePath(webkit_component)); | 
|   70   FilePath combined_path = path.Append(component); |   70   base::FilePath combined_path = path.Append(component); | 
|   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   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   FilePath file_path(webkit_base::WebStringToFilePath(path)); |   81   base::FilePath file_path(webkit_base::WebStringToFilePath(path)); | 
|   82   file_util::AbsolutePath(&file_path); |   82   file_util::AbsolutePath(&file_path); | 
|   83   return webkit_base::FilePathStringToWebString(file_path.value()); |   83   return webkit_base::FilePathStringToWebString(file_path.value()); | 
|   84 } |   84 } | 
|   85  |   85  | 
|   86 bool WebFileUtilitiesImpl::isDirectory(const WebString& path) { |   86 bool WebFileUtilitiesImpl::isDirectory(const WebString& path) { | 
|   87   FilePath file_path(webkit_base::WebStringToFilePath(path)); |   87   base::FilePath file_path(webkit_base::WebStringToFilePath(path)); | 
|   88   return file_util::DirectoryExists(file_path); |   88   return file_util::DirectoryExists(file_path); | 
|   89 } |   89 } | 
|   90  |   90  | 
|   91 WebKit::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { |   91 WebKit::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { | 
|   92   return net::FilePathToFileURL(webkit_base::WebStringToFilePath(path)); |   92   return net::FilePathToFileURL(webkit_base::WebStringToFilePath(path)); | 
|   93 } |   93 } | 
|   94  |   94  | 
|   95 base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path, |   95 base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path, | 
|   96                                                   int mode) { |   96                                                   int mode) { | 
|   97   if (sandbox_enabled_) { |   97   if (sandbox_enabled_) { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  140  |  140  | 
|  141 int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, |  141 int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, | 
|  142                                       const char* data, |  142                                       const char* data, | 
|  143                                       int length) { |  143                                       int length) { | 
|  144   if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) |  144   if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) | 
|  145     return -1; |  145     return -1; | 
|  146   return base::WritePlatformFileCurPosNoBestEffort(handle, data, length); |  146   return base::WritePlatformFileCurPosNoBestEffort(handle, data, length); | 
|  147 } |  147 } | 
|  148  |  148  | 
|  149 }  // namespace webkit_glue |  149 }  // namespace webkit_glue | 
| OLD | NEW |