OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return CreateAndOpenTemporaryFileInDir(directory, path); | 419 return CreateAndOpenTemporaryFileInDir(directory, path); |
420 } | 420 } |
421 | 421 |
422 FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { | 422 FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { |
423 int fd = CreateAndOpenFdForTemporaryFile(dir, path); | 423 int fd = CreateAndOpenFdForTemporaryFile(dir, path); |
424 if (fd < 0) | 424 if (fd < 0) |
425 return NULL; | 425 return NULL; |
426 | 426 |
427 return fdopen(fd, "a+"); | 427 return fdopen(fd, "a+"); |
428 } | 428 } |
429 // TODO(port): implement me. | 429 |
430 bool CreateTemporaryFileInDir(const FilePath& dir, | 430 bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) { |
431 FilePath* temp_file) { | 431 int fd = CreateAndOpenFdForTemporaryFile(dir, temp_file); |
432 NOTREACHED(); | 432 return ((fd >= 0) && !close(fd)); |
433 return false; | |
434 } | 433 } |
435 | 434 |
436 bool CreateNewTempDirectory(const FilePath::StringType& prefix, | 435 bool CreateNewTempDirectory(const FilePath::StringType& prefix, |
437 FilePath* new_temp_path) { | 436 FilePath* new_temp_path) { |
438 FilePath tmpdir; | 437 FilePath tmpdir; |
439 if (!GetTempDir(&tmpdir)) | 438 if (!GetTempDir(&tmpdir)) |
440 return false; | 439 return false; |
441 tmpdir = tmpdir.Append(kTempFileName); | 440 tmpdir = tmpdir.Append(kTempFileName); |
442 std::string tmpdir_string = tmpdir.value(); | 441 std::string tmpdir_string = tmpdir.value(); |
443 // this should be OK since mkdtemp just replaces characters in place | 442 // this should be OK since mkdtemp just replaces characters in place |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 munmap(data_, length_); | 736 munmap(data_, length_); |
738 if (file_ != -1) | 737 if (file_ != -1) |
739 close(file_); | 738 close(file_); |
740 | 739 |
741 data_ = NULL; | 740 data_ = NULL; |
742 length_ = 0; | 741 length_ = 0; |
743 file_ = -1; | 742 file_ = -1; |
744 } | 743 } |
745 | 744 |
746 } // namespace file_util | 745 } // namespace file_util |
OLD | NEW |