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

Unified Diff: components/filesystem/shared_impl.cc

Issue 1158253002: mandoline filesystem: Rewrite using base::File. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Get the error from the right object. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/filesystem/shared_impl.h ('k') | components/filesystem/util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/filesystem/shared_impl.cc
diff --git a/components/filesystem/shared_impl.cc b/components/filesystem/shared_impl.cc
deleted file mode 100644
index d1c7f8fd5d37b155eb4b597d6a9011d4b857a99a..0000000000000000000000000000000000000000
--- a/components/filesystem/shared_impl.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/filesystem/shared_impl.h"
-
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "base/logging.h"
-#include "components/filesystem/futimens.h"
-#include "components/filesystem/util.h"
-
-namespace filesystem {
-
-void StatFD(int fd, FileType type, const StatFDCallback& callback) {
- DCHECK_NE(fd, -1);
-
- struct stat buf;
- if (fstat(fd, &buf) != 0) {
- callback.Run(ErrnoToError(errno), nullptr);
- return;
- }
-
- FileInformationPtr file_info(FileInformation::New());
- file_info->type = type;
- // Only fill in |size| for files.
- if (S_ISREG(buf.st_mode)) {
- file_info->size = static_cast<int64_t>(buf.st_size);
- } else {
- LOG_IF(WARNING, !S_ISDIR(buf.st_mode))
- << "Unexpected fstat() of special file";
- file_info->size = 0;
- }
- file_info->atime = Timespec::New();
- file_info->mtime = Timespec::New();
-#if defined(OS_ANDROID)
- file_info->atime->seconds = static_cast<int64_t>(buf.st_atime);
- file_info->atime->nanoseconds = static_cast<int32_t>(buf.st_atime_nsec);
- file_info->mtime->seconds = static_cast<int64_t>(buf.st_mtime);
- file_info->mtime->nanoseconds = static_cast<int32_t>(buf.st_mtime_nsec);
-#else
- file_info->atime->seconds = static_cast<int64_t>(buf.st_atim.tv_sec);
- file_info->atime->nanoseconds = static_cast<int32_t>(buf.st_atim.tv_nsec);
- file_info->mtime->seconds = static_cast<int64_t>(buf.st_mtim.tv_sec);
- file_info->mtime->nanoseconds = static_cast<int32_t>(buf.st_mtim.tv_nsec);
-#endif
-
- callback.Run(ERROR_OK, file_info.Pass());
-}
-
-void TouchFD(int fd,
- TimespecOrNowPtr atime,
- TimespecOrNowPtr mtime,
- const TouchFDCallback& callback) {
- DCHECK_NE(fd, -1);
-
- struct timespec times[2];
- if (Error error = TimespecOrNowToStandardTimespec(atime.get(), &times[0])) {
- callback.Run(error);
- return;
- }
- if (Error error = TimespecOrNowToStandardTimespec(mtime.get(), &times[1])) {
- callback.Run(error);
- return;
- }
-
- if (futimens(fd, times) != 0) {
- callback.Run(ErrnoToError(errno));
- return;
- }
-
- callback.Run(ERROR_OK);
-}
-
-} // namespace filesystem
« no previous file with comments | « components/filesystem/shared_impl.h ('k') | components/filesystem/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698