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

Side by Side Diff: base/files/file_util_posix.cc

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Also fix unit tests Created 4 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 unified diff | Download patch
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/files/file_util.h" 5 #include "base/files/file_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <libgen.h> 10 #include <libgen.h>
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 550 }
551 551
552 bool CreateTemporaryDirInDir(const FilePath& base_dir, 552 bool CreateTemporaryDirInDir(const FilePath& base_dir,
553 const FilePath::StringType& prefix, 553 const FilePath::StringType& prefix,
554 FilePath* new_dir) { 554 FilePath* new_dir) {
555 FilePath::StringType mkdtemp_template = prefix; 555 FilePath::StringType mkdtemp_template = prefix;
556 mkdtemp_template.append(FILE_PATH_LITERAL("XXXXXX")); 556 mkdtemp_template.append(FILE_PATH_LITERAL("XXXXXX"));
557 return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir); 557 return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir);
558 } 558 }
559 559
560 bool CreateNewTempDirectory(const FilePath::StringType& prefix, 560 bool CreateNewTempDirectory(const FilePath::StringType& /* prefix */,
561 FilePath* new_temp_path) { 561 FilePath* new_temp_path) {
562 FilePath tmpdir; 562 FilePath tmpdir;
563 if (!GetTempDir(&tmpdir)) 563 if (!GetTempDir(&tmpdir))
564 return false; 564 return false;
565 565
566 return CreateTemporaryDirInDirImpl(tmpdir, TempFileName(), new_temp_path); 566 return CreateTemporaryDirInDirImpl(tmpdir, TempFileName(), new_temp_path);
567 } 567 }
568 568
569 bool CreateDirectoryAndGetError(const FilePath& full_path, 569 bool CreateDirectoryAndGetError(const FilePath& full_path,
570 File::Error* error) { 570 File::Error* error) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 #if defined(OS_LINUX) 838 #if defined(OS_LINUX)
839 bool use_dev_shm = true; 839 bool use_dev_shm = true;
840 if (executable) { 840 if (executable) {
841 static const bool s_dev_shm_executable = DetermineDevShmExecutable(); 841 static const bool s_dev_shm_executable = DetermineDevShmExecutable();
842 use_dev_shm = s_dev_shm_executable; 842 use_dev_shm = s_dev_shm_executable;
843 } 843 }
844 if (use_dev_shm) { 844 if (use_dev_shm) {
845 *path = FilePath("/dev/shm"); 845 *path = FilePath("/dev/shm");
846 return true; 846 return true;
847 } 847 }
848 #else
849 (void)executable; // avoid unused warning when !defined(OS_LINUX)
danakj 2016/05/23 02:59:54 capitalize and punctuate comment senetences
Luis Héctor Chávez 2016/05/24 15:27:53 Done.
848 #endif 850 #endif
849 return GetTempDir(path); 851 return GetTempDir(path);
850 } 852 }
851 #endif // !defined(OS_ANDROID) 853 #endif // !defined(OS_ANDROID)
852 854
853 #if !defined(OS_MACOSX) 855 #if !defined(OS_MACOSX)
854 // Mac has its own implementation, this is for all other Posix systems. 856 // Mac has its own implementation, this is for all other Posix systems.
855 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { 857 bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
856 ThreadRestrictions::AssertIOAllowed(); 858 ThreadRestrictions::AssertIOAllowed();
857 File infile; 859 File infile;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return false; 928 return false;
927 929
928 DeleteFile(from_path, true); 930 DeleteFile(from_path, true);
929 return true; 931 return true;
930 } 932 }
931 933
932 } // namespace internal 934 } // namespace internal
933 935
934 #endif // !defined(OS_NACL_NONSFI) 936 #endif // !defined(OS_NACL_NONSFI)
935 } // namespace base 937 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698