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

Unified Diff: base/file_util_posix.cc

Issue 46303005: Fix chrome upload with content uri (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing mmenke's comments Created 7 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 side-by-side diff with in-line comments
Download patch
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 296950bebd8bd69d06ee978bcb5a56971643e971..ea9905cf3d354e95d011764398b302cf0648b5dd 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -48,6 +48,7 @@
#include "base/time/time.h"
#if defined(OS_ANDROID)
+#include "base/android/content_uri_utils.h"
#include "base/os_compat_android.h"
#endif
@@ -79,6 +80,12 @@ static int CallLstat(const char *path, stat_wrapper_t *sb) {
ThreadRestrictions::AssertIOAllowed();
return lstat64(path, sb);
}
+#if defined(OS_ANDROID)
+static int CallFstat(int fd, stat_wrapper_t *sb) {
+ ThreadRestrictions::AssertIOAllowed();
+ return fstat64(fd, sb);
+}
+#endif
#endif
// Helper for NormalizeFilePath(), defined below.
@@ -308,6 +315,11 @@ bool CopyDirectory(const FilePath& from_path,
bool PathExists(const FilePath& path) {
ThreadRestrictions::AssertIOAllowed();
+#if defined(OS_ANDROID)
+ if (path.IsContentUrl()) {
+ return ContentUrlExists(path);
+ }
kinuko 2013/11/06 01:42:05 nit: usually we use no { } for single-line block i
qinmin 2013/11/07 01:13:35 Done.
+#endif
return access(path.value().c_str(), F_OK) == 0;
}
@@ -569,8 +581,21 @@ bool IsLink(const FilePath& file_path) {
bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
stat_wrapper_t file_info;
+#if defined(OS_ANDROID)
+ if (file_path.IsContentUrl()) {
+ int fd = OpenContentUrlForRead(file_path);
+ if (fd < 0)
+ return false;
+ ScopedFD scoped_fd(&fd);
+ if (base::CallFstat(fd, &file_info) != 0)
+ return false;
+ } else {
+#endif
if (CallStat(file_path.value().c_str(), &file_info) != 0)
joth 2013/11/06 00:27:08 It looks like CallStat() is already intended to ha
qinmin 2013/11/07 01:13:35 I think I would rather keep it separate. CallStat(
return false;
+#if defined(OS_ANDROID)
+ }
+#endif
results->is_directory = S_ISDIR(file_info.st_mode);
results->size = file_info.st_size;
#if defined(OS_MACOSX)
« no previous file with comments | « base/base.gypi ('k') | base/files/file_path.h » ('j') | net/base/file_stream_context.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698