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 FilePath* new_dir, | 431 FilePath* new_dir) { |
432 bool loosen_permissions) { | |
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 posible to call this function with | |
437 // loosen_permissions == true on non-windows plarforms. | |
438 CHECK(!loosen_permissions); | |
439 | |
440 FilePath::StringType mkdtemp_template = prefix; | 432 FilePath::StringType mkdtemp_template = prefix; |
441 mkdtemp_template.append(FILE_PATH_LITERAL("XXXXXX")); | 433 mkdtemp_template.append(FILE_PATH_LITERAL("XXXXXX")); |
442 return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir); | 434 return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir); |
443 } | 435 } |
444 | 436 |
445 bool CreateNewTempDirectory(const FilePath::StringType& prefix, | 437 bool CreateNewTempDirectory(const FilePath::StringType& prefix, |
446 FilePath* new_temp_path) { | 438 FilePath* new_temp_path) { |
447 FilePath tmpdir; | 439 FilePath tmpdir; |
448 if (!GetTempDir(&tmpdir)) | 440 if (!GetTempDir(&tmpdir)) |
449 return false; | 441 return false; |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 if (HANDLE_EINTR(close(infile)) < 0) | 831 if (HANDLE_EINTR(close(infile)) < 0) |
840 result = false; | 832 result = false; |
841 if (HANDLE_EINTR(close(outfile)) < 0) | 833 if (HANDLE_EINTR(close(outfile)) < 0) |
842 result = false; | 834 result = false; |
843 | 835 |
844 return result; | 836 return result; |
845 } | 837 } |
846 #endif // defined(OS_MACOSX) | 838 #endif // defined(OS_MACOSX) |
847 | 839 |
848 } // namespace file_util | 840 } // namespace file_util |
OLD | NEW |