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

Side by Side Diff: base/file_util_posix.cc

Issue 5286010: Start using file_util symlink code, now that it's available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review change Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « base/command_line.cc ('k') | base/process_util_linux.cc » ('j') | 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 symlink_path.value().c_str()) != -1; 381 symlink_path.value().c_str()) != -1;
382 } 382 }
383 383
384 bool ReadSymbolicLink(const FilePath& symlink_path, 384 bool ReadSymbolicLink(const FilePath& symlink_path,
385 FilePath* target_path) { 385 FilePath* target_path) {
386 DCHECK(!symlink_path.empty()); 386 DCHECK(!symlink_path.empty());
387 DCHECK(target_path); 387 DCHECK(target_path);
388 char buf[PATH_MAX]; 388 char buf[PATH_MAX];
389 ssize_t count = ::readlink(symlink_path.value().c_str(), buf, arraysize(buf)); 389 ssize_t count = ::readlink(symlink_path.value().c_str(), buf, arraysize(buf));
390 390
391 if (count <= 0) 391 if (count <= 0) {
392 target_path->clear();
392 return false; 393 return false;
394 }
393 395
394 *target_path = FilePath(FilePath::StringType(buf, count)); 396 *target_path = FilePath(FilePath::StringType(buf, count));
395
396 return true; 397 return true;
397 } 398 }
398 399
399 // Creates and opens a temporary file in |directory|, returning the 400 // Creates and opens a temporary file in |directory|, returning the
400 // file descriptor. |path| is set to the temporary file path. 401 // file descriptor. |path| is set to the temporary file path.
401 // This function does NOT unlink() the file. 402 // This function does NOT unlink() the file.
402 int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) { 403 int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) {
403 base::ThreadRestrictions::AssertIOAllowed(); // For call to mkstemp(). 404 base::ThreadRestrictions::AssertIOAllowed(); // For call to mkstemp().
404 *path = directory.Append(kTempFileName); 405 *path = directory.Append(kTempFileName);
405 const std::string& tmpdir_string = path->value(); 406 const std::string& tmpdir_string = path->value();
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (HANDLE_EINTR(close(infile)) < 0) 881 if (HANDLE_EINTR(close(infile)) < 0)
881 result = false; 882 result = false;
882 if (HANDLE_EINTR(close(outfile)) < 0) 883 if (HANDLE_EINTR(close(outfile)) < 0)
883 result = false; 884 result = false;
884 885
885 return result; 886 return result;
886 } 887 }
887 #endif // defined(OS_MACOSX) 888 #endif // defined(OS_MACOSX)
888 889
889 } // namespace file_util 890 } // namespace file_util
OLDNEW
« no previous file with comments | « base/command_line.cc ('k') | base/process_util_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698