OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_util.h" | 5 #include "base/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 <fnmatch.h> | 10 #include <fnmatch.h> |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 char* buffer = const_cast<char*>(sub_dir_string.c_str()); | 421 char* buffer = const_cast<char*>(sub_dir_string.c_str()); |
422 char* dtemp = mkdtemp(buffer); | 422 char* dtemp = mkdtemp(buffer); |
423 if (!dtemp) | 423 if (!dtemp) |
424 return false; | 424 return false; |
425 *new_dir = FilePath(dtemp); | 425 *new_dir = FilePath(dtemp); |
426 return true; | 426 return true; |
427 } | 427 } |
428 | 428 |
429 bool CreateTemporaryDirInDir(const FilePath& base_dir, | 429 bool CreateTemporaryDirInDir(const FilePath& base_dir, |
430 const FilePath::StringType& prefix, | 430 const FilePath::StringType& prefix, |
| 431 bool loosen_permissions, |
431 FilePath* new_dir) { | 432 FilePath* new_dir) { |
| 433 // To understand crbug/35198, the ability to call this |
| 434 // this function on windows while giving loose permissions |
| 435 // to the resulting directory has been temporarily added. |
| 436 // It should not be possible to call this function with |
| 437 // loosen_permissions == true on non-windows platforms. |
| 438 DCHECK(!loosen_permissions); |
| 439 |
432 FilePath::StringType mkdtemp_template = prefix; | 440 FilePath::StringType mkdtemp_template = prefix; |
433 mkdtemp_template.append(FILE_PATH_LITERAL("XXXXXX")); | 441 mkdtemp_template.append(FILE_PATH_LITERAL("XXXXXX")); |
434 return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir); | 442 return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir); |
435 } | 443 } |
436 | 444 |
437 bool CreateNewTempDirectory(const FilePath::StringType& prefix, | 445 bool CreateNewTempDirectory(const FilePath::StringType& prefix, |
438 FilePath* new_temp_path) { | 446 FilePath* new_temp_path) { |
439 FilePath tmpdir; | 447 FilePath tmpdir; |
440 if (!GetTempDir(&tmpdir)) | 448 if (!GetTempDir(&tmpdir)) |
441 return false; | 449 return false; |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 if (HANDLE_EINTR(close(infile)) < 0) | 839 if (HANDLE_EINTR(close(infile)) < 0) |
832 result = false; | 840 result = false; |
833 if (HANDLE_EINTR(close(outfile)) < 0) | 841 if (HANDLE_EINTR(close(outfile)) < 0) |
834 result = false; | 842 result = false; |
835 | 843 |
836 return result; | 844 return result; |
837 } | 845 } |
838 #endif // defined(OS_MACOSX) | 846 #endif // defined(OS_MACOSX) |
839 | 847 |
840 } // namespace file_util | 848 } // namespace file_util |
OLD | NEW |