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

Side by Side Diff: base/file_util_posix.cc

Issue 3067013: posix: print error message when mkdtemp fails. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 FilePath* new_dir) { 413 FilePath* new_dir) {
414 CHECK(name_tmpl.find("XXXXXX") != FilePath::StringType::npos) 414 CHECK(name_tmpl.find("XXXXXX") != FilePath::StringType::npos)
415 << "Directory name template must contain \"XXXXXX\"."; 415 << "Directory name template must contain \"XXXXXX\".";
416 416
417 FilePath sub_dir = base_dir.Append(name_tmpl); 417 FilePath sub_dir = base_dir.Append(name_tmpl);
418 std::string sub_dir_string = sub_dir.value(); 418 std::string sub_dir_string = sub_dir.value();
419 419
420 // this should be OK since mkdtemp just replaces characters in place 420 // this should be OK since mkdtemp just replaces characters in place
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 DPLOG(ERROR) << "mkdtemp";
Nico 2010/07/28 20:57:52 << errno? or does DPLOG do that already?
424 return false; 425 return false;
426 }
425 *new_dir = FilePath(dtemp); 427 *new_dir = FilePath(dtemp);
426 return true; 428 return true;
427 } 429 }
428 430
429 bool CreateTemporaryDirInDir(const FilePath& base_dir, 431 bool CreateTemporaryDirInDir(const FilePath& base_dir,
430 const FilePath::StringType& prefix, 432 const FilePath::StringType& prefix,
431 bool loosen_permissions, 433 bool loosen_permissions,
432 FilePath* new_dir) { 434 FilePath* new_dir) {
433 // To understand crbug/35198, the ability to call this 435 // To understand crbug/35198, the ability to call this
434 // this function on windows while giving loose permissions 436 // this function on windows while giving loose permissions
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 if (HANDLE_EINTR(close(infile)) < 0) 841 if (HANDLE_EINTR(close(infile)) < 0)
840 result = false; 842 result = false;
841 if (HANDLE_EINTR(close(outfile)) < 0) 843 if (HANDLE_EINTR(close(outfile)) < 0)
842 result = false; 844 result = false;
843 845
844 return result; 846 return result;
845 } 847 }
846 #endif // defined(OS_MACOSX) 848 #endif // defined(OS_MACOSX)
847 849
848 } // namespace file_util 850 } // namespace file_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698