| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <fnmatch.h> | 9 #include <fnmatch.h> |
| 10 #include <fts.h> | 10 #include <fts.h> |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // this should be OK since mkstemp just replaces characters in place | 259 // this should be OK since mkstemp just replaces characters in place |
| 260 char* buffer = const_cast<char*>(tmpdir_string.c_str()); | 260 char* buffer = const_cast<char*>(tmpdir_string.c_str()); |
| 261 int fd = mkstemp(buffer); | 261 int fd = mkstemp(buffer); |
| 262 if (fd < 0) | 262 if (fd < 0) |
| 263 return false; | 263 return false; |
| 264 *temp_file = UTF8ToWide(buffer); | 264 *temp_file = UTF8ToWide(buffer); |
| 265 close(fd); | 265 close(fd); |
| 266 return true; | 266 return true; |
| 267 } | 267 } |
| 268 | 268 |
| 269 bool CreateTemporaryFileNameInDir(const std::wstring& dir, |
| 270 std::wstring* temp_file) { |
| 271 // Not implemented yet. |
| 272 NOTREACHED(); |
| 273 return false; |
| 274 } |
| 275 |
| 269 bool CreateNewTempDirectory(const std::wstring& prefix, | 276 bool CreateNewTempDirectory(const std::wstring& prefix, |
| 270 std::wstring* new_temp_path) { | 277 std::wstring* new_temp_path) { |
| 271 std::wstring tmpdir; | 278 std::wstring tmpdir; |
| 272 if (!GetTempDir(&tmpdir)) | 279 if (!GetTempDir(&tmpdir)) |
| 273 return false; | 280 return false; |
| 274 AppendToPath(&tmpdir, kTempFileName); | 281 AppendToPath(&tmpdir, kTempFileName); |
| 275 std::string tmpdir_string = WideToUTF8(tmpdir); | 282 std::string tmpdir_string = WideToUTF8(tmpdir); |
| 276 // this should be OK since mkdtemp just replaces characters in place | 283 // this should be OK since mkdtemp just replaces characters in place |
| 277 char* buffer = const_cast<char*>(tmpdir_string.c_str()); | 284 char* buffer = const_cast<char*>(tmpdir_string.c_str()); |
| 278 char* dtemp = mkdtemp(buffer); | 285 char* dtemp = mkdtemp(buffer); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); | 448 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); |
| 442 } else if (fts_ent->fts_info == FTS_F) { | 449 } else if (fts_ent->fts_info == FTS_F) { |
| 443 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); | 450 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); |
| 444 } | 451 } |
| 445 // TODO(erikkay) - verify that the other fts_info types aren't interesting | 452 // TODO(erikkay) - verify that the other fts_info types aren't interesting |
| 446 return Next(); | 453 return Next(); |
| 447 } | 454 } |
| 448 | 455 |
| 449 | 456 |
| 450 } // namespace file_util | 457 } // namespace file_util |
| OLD | NEW |