Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: base/file_util_posix.cc

Issue 7618037: base: Rename FileEnumerator::FILE_TYPE to FileEnumerator::FileType. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util.cc ('k') | base/file_util_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return ret; 165 return ret;
166 } 166 }
167 if (!S_ISDIR(file_info.st_mode)) 167 if (!S_ISDIR(file_info.st_mode))
168 return (unlink(path_str) == 0); 168 return (unlink(path_str) == 0);
169 if (!recursive) 169 if (!recursive)
170 return (rmdir(path_str) == 0); 170 return (rmdir(path_str) == 0);
171 171
172 bool success = true; 172 bool success = true;
173 std::stack<std::string> directories; 173 std::stack<std::string> directories;
174 directories.push(path.value()); 174 directories.push(path.value());
175 FileEnumerator traversal(path, true, static_cast<FileEnumerator::FILE_TYPE>( 175 FileEnumerator traversal(path, true, static_cast<FileEnumerator::FileType>(
176 FileEnumerator::FILES | FileEnumerator::DIRECTORIES | 176 FileEnumerator::FILES | FileEnumerator::DIRECTORIES |
177 FileEnumerator::SHOW_SYM_LINKS)); 177 FileEnumerator::SHOW_SYM_LINKS));
178 for (FilePath current = traversal.Next(); success && !current.empty(); 178 for (FilePath current = traversal.Next(); success && !current.empty();
179 current = traversal.Next()) { 179 current = traversal.Next()) {
180 FileEnumerator::FindInfo info; 180 FileEnumerator::FindInfo info;
181 traversal.GetFindInfo(&info); 181 traversal.GetFindInfo(&info);
182 182
183 if (S_ISDIR(info.stat.st_mode)) 183 if (S_ISDIR(info.stat.st_mode))
184 directories.push(current.value()); 184 directories.push(current.value());
185 else 185 else
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 FilePath real_from_path = from_path; 254 FilePath real_from_path = from_path;
255 if (!AbsolutePath(&real_from_path)) 255 if (!AbsolutePath(&real_from_path))
256 return false; 256 return false;
257 if (real_to_path.value().size() >= real_from_path.value().size() && 257 if (real_to_path.value().size() >= real_from_path.value().size() &&
258 real_to_path.value().compare(0, real_from_path.value().size(), 258 real_to_path.value().compare(0, real_from_path.value().size(),
259 real_from_path.value()) == 0) 259 real_from_path.value()) == 0)
260 return false; 260 return false;
261 261
262 bool success = true; 262 bool success = true;
263 FileEnumerator::FILE_TYPE traverse_type = 263 FileEnumerator::FileType traverse_type =
264 static_cast<FileEnumerator::FILE_TYPE>(FileEnumerator::FILES | 264 static_cast<FileEnumerator::FileType>(FileEnumerator::FILES |
265 FileEnumerator::SHOW_SYM_LINKS); 265 FileEnumerator::SHOW_SYM_LINKS);
266 if (recursive) 266 if (recursive)
267 traverse_type = static_cast<FileEnumerator::FILE_TYPE>( 267 traverse_type = static_cast<FileEnumerator::FileType>(
268 traverse_type | FileEnumerator::DIRECTORIES); 268 traverse_type | FileEnumerator::DIRECTORIES);
269 FileEnumerator traversal(from_path, recursive, traverse_type); 269 FileEnumerator traversal(from_path, recursive, traverse_type);
270 270
271 // We have to mimic windows behavior here. |to_path| may not exist yet, 271 // We have to mimic windows behavior here. |to_path| may not exist yet,
272 // start the loop with |to_path|. 272 // start the loop with |to_path|.
273 FileEnumerator::FindInfo info; 273 FileEnumerator::FindInfo info;
274 FilePath current = from_path; 274 FilePath current = from_path;
275 if (stat(from_path.value().c_str(), &info.stat) < 0) { 275 if (stat(from_path.value().c_str(), &info.stat) < 0) {
276 LOG(ERROR) << "CopyDirectory() couldn't stat source directory: " << 276 LOG(ERROR) << "CopyDirectory() couldn't stat source directory: " <<
277 from_path.value() << " errno = " << errno; 277 from_path.value() << " errno = " << errno;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 base::ThreadRestrictions::AssertIOAllowed(); 635 base::ThreadRestrictions::AssertIOAllowed();
636 int ret = chdir(path.value().c_str()); 636 int ret = chdir(path.value().c_str());
637 return !ret; 637 return !ret;
638 } 638 }
639 639
640 /////////////////////////////////////////////// 640 ///////////////////////////////////////////////
641 // FileEnumerator 641 // FileEnumerator
642 642
643 FileEnumerator::FileEnumerator(const FilePath& root_path, 643 FileEnumerator::FileEnumerator(const FilePath& root_path,
644 bool recursive, 644 bool recursive,
645 FileEnumerator::FILE_TYPE file_type) 645 FileType file_type)
646 : current_directory_entry_(0), 646 : current_directory_entry_(0),
647 root_path_(root_path), 647 root_path_(root_path),
648 recursive_(recursive), 648 recursive_(recursive),
649 file_type_(file_type) { 649 file_type_(file_type) {
650 // INCLUDE_DOT_DOT must not be specified if recursive. 650 // INCLUDE_DOT_DOT must not be specified if recursive.
651 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); 651 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_)));
652 pending_paths_.push(root_path); 652 pending_paths_.push(root_path);
653 } 653 }
654 654
655 FileEnumerator::FileEnumerator(const FilePath& root_path, 655 FileEnumerator::FileEnumerator(const FilePath& root_path,
656 bool recursive, 656 bool recursive,
657 FileEnumerator::FILE_TYPE file_type, 657 FileType file_type,
658 const FilePath::StringType& pattern) 658 const FilePath::StringType& pattern)
659 : current_directory_entry_(0), 659 : current_directory_entry_(0),
660 root_path_(root_path), 660 root_path_(root_path),
661 recursive_(recursive), 661 recursive_(recursive),
662 file_type_(file_type), 662 file_type_(file_type),
663 pattern_(root_path.Append(pattern).value()) { 663 pattern_(root_path.Append(pattern).value()) {
664 // INCLUDE_DOT_DOT must not be specified if recursive. 664 // INCLUDE_DOT_DOT must not be specified if recursive.
665 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); 665 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_)));
666 // The Windows version of this code appends the pattern to the root_path, 666 // The Windows version of this code appends the pattern to the root_path,
667 // potentially only matching against items in the top-most directory. 667 // potentially only matching against items in the top-most directory.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 if (HANDLE_EINTR(close(infile)) < 0) 934 if (HANDLE_EINTR(close(infile)) < 0)
935 result = false; 935 result = false;
936 if (HANDLE_EINTR(close(outfile)) < 0) 936 if (HANDLE_EINTR(close(outfile)) < 0)
937 result = false; 937 result = false;
938 938
939 return result; 939 return result;
940 } 940 }
941 #endif // defined(OS_MACOSX) 941 #endif // defined(OS_MACOSX)
942 942
943 } // namespace file_util 943 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.cc ('k') | base/file_util_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698