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