| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |