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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 break; | 100 break; |
101 } | 101 } |
102 fts_ent = fts_read(fts); | 102 fts_ent = fts_read(fts); |
103 } | 103 } |
104 fts_close(fts); | 104 fts_close(fts); |
105 } | 105 } |
106 return success; | 106 return success; |
107 } | 107 } |
108 | 108 |
109 bool Move(const FilePath& from_path, const FilePath& to_path) { | 109 bool Move(const FilePath& from_path, const FilePath& to_path) { |
110 return (rename(from_path.value().c_str(), | 110 if (rename(from_path.value().c_str(), to_path.value().c_str()) == 0) |
111 to_path.value().c_str()) == 0); | 111 return true; |
| 112 |
| 113 if (!CopyDirectory(from_path, to_path, true)) |
| 114 return false; |
| 115 |
| 116 Delete(from_path, true); |
| 117 return true; |
112 } | 118 } |
113 | 119 |
114 bool CopyDirectory(const FilePath& from_path, | 120 bool CopyDirectory(const FilePath& from_path, |
115 const FilePath& to_path, | 121 const FilePath& to_path, |
116 bool recursive) { | 122 bool recursive) { |
117 // Some old callers of CopyDirectory want it to support wildcards. | 123 // Some old callers of CopyDirectory want it to support wildcards. |
118 // After some discussion, we decided to fix those callers. | 124 // After some discussion, we decided to fix those callers. |
119 // Break loudly here if anyone tries to do this. | 125 // Break loudly here if anyone tries to do this. |
120 // TODO(evanm): remove this once we're sure it's ok. | 126 // TODO(evanm): remove this once we're sure it's ok. |
121 DCHECK(to_path.value().find('*') == std::string::npos); | 127 DCHECK(to_path.value().find('*') == std::string::npos); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 munmap(data_, length_); | 580 munmap(data_, length_); |
575 if (file_ != -1) | 581 if (file_ != -1) |
576 close(file_); | 582 close(file_); |
577 | 583 |
578 data_ = NULL; | 584 data_ = NULL; |
579 length_ = 0; | 585 length_ = 0; |
580 file_ = -1; | 586 file_ = -1; |
581 } | 587 } |
582 | 588 |
583 } // namespace file_util | 589 } // namespace file_util |
OLD | NEW |