OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/files/file_util.h" | 5 #include "base/files/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 <libgen.h> | 10 #include <libgen.h> |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // the suffix after from_path to to_path to create the target_path. | 314 // the suffix after from_path to to_path to create the target_path. |
315 FilePath target_path(to_path); | 315 FilePath target_path(to_path); |
316 if (from_path_base != current) { | 316 if (from_path_base != current) { |
317 if (!from_path_base.AppendRelativePath(current, &target_path)) { | 317 if (!from_path_base.AppendRelativePath(current, &target_path)) { |
318 success = false; | 318 success = false; |
319 break; | 319 break; |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 if (S_ISDIR(from_stat.st_mode)) { | 323 if (S_ISDIR(from_stat.st_mode)) { |
324 if (mkdir(target_path.value().c_str(), from_stat.st_mode & 01777) != 0 && | 324 if (mkdir(target_path.value().c_str(), |
| 325 (from_stat.st_mode & 01777) | S_IRUSR | S_IXUSR | S_IWUSR) != |
| 326 0 && |
325 errno != EEXIST) { | 327 errno != EEXIST) { |
326 DLOG(ERROR) << "CopyDirectory() couldn't create directory: " | 328 DLOG(ERROR) << "CopyDirectory() couldn't create directory: " |
327 << target_path.value() << " errno = " << errno; | 329 << target_path.value() << " errno = " << errno; |
328 success = false; | 330 success = false; |
329 } | 331 } |
330 } else if (S_ISREG(from_stat.st_mode)) { | 332 } else if (S_ISREG(from_stat.st_mode)) { |
331 if (!CopyFile(current, target_path)) { | 333 if (!CopyFile(current, target_path)) { |
332 DLOG(ERROR) << "CopyDirectory() couldn't create file: " | 334 DLOG(ERROR) << "CopyDirectory() couldn't create file: " |
333 << target_path.value(); | 335 << target_path.value(); |
334 success = false; | 336 success = false; |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 result = false; | 916 result = false; |
915 if (IGNORE_EINTR(close(outfile)) < 0) | 917 if (IGNORE_EINTR(close(outfile)) < 0) |
916 result = false; | 918 result = false; |
917 | 919 |
918 return result; | 920 return result; |
919 } | 921 } |
920 #endif // !defined(OS_MACOSX) | 922 #endif // !defined(OS_MACOSX) |
921 | 923 |
922 } // namespace internal | 924 } // namespace internal |
923 } // namespace base | 925 } // namespace base |
OLD | NEW |