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

Side by Side Diff: base/file_util_posix.cc

Issue 6085015: Order function definitions in base/ according to the header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lrn2merge Created 9 years, 11 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.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 // potentially only matching against items in the top-most directory. 634 // potentially only matching against items in the top-most directory.
635 // Do the same here. 635 // Do the same here.
636 if (pattern.size() == 0) 636 if (pattern.size() == 0)
637 pattern_ = FilePath::StringType(); 637 pattern_ = FilePath::StringType();
638 pending_paths_.push(root_path); 638 pending_paths_.push(root_path);
639 } 639 }
640 640
641 FileEnumerator::~FileEnumerator() { 641 FileEnumerator::~FileEnumerator() {
642 } 642 }
643 643
644 void FileEnumerator::GetFindInfo(FindInfo* info) {
645 DCHECK(info);
646
647 if (current_directory_entry_ >= directory_entries_.size())
648 return;
649
650 DirectoryEntryInfo* cur_entry = &directory_entries_[current_directory_entry_];
651 memcpy(&(info->stat), &(cur_entry->stat), sizeof(info->stat));
652 info->filename.assign(cur_entry->filename.value());
653 }
654
655 bool FileEnumerator::IsDirectory(const FindInfo& info) {
656 return S_ISDIR(info.stat.st_mode);
657 }
658
659 // static
660 FilePath FileEnumerator::GetFilename(const FindInfo& find_info) {
661 return FilePath(find_info.filename);
662 }
663
664 FilePath FileEnumerator::Next() { 644 FilePath FileEnumerator::Next() {
665 ++current_directory_entry_; 645 ++current_directory_entry_;
666 646
667 // While we've exhausted the entries in the current directory, do the next 647 // While we've exhausted the entries in the current directory, do the next
668 while (current_directory_entry_ >= directory_entries_.size()) { 648 while (current_directory_entry_ >= directory_entries_.size()) {
669 if (pending_paths_.empty()) 649 if (pending_paths_.empty())
670 return FilePath(); 650 return FilePath();
671 651
672 root_path_ = pending_paths_.top(); 652 root_path_ = pending_paths_.top();
673 root_path_ = root_path_.StripTrailingSeparators(); 653 root_path_ = root_path_.StripTrailingSeparators();
(...skipping 21 matching lines...) Expand all
695 if ((S_ISDIR(i->stat.st_mode) && (file_type_ & DIRECTORIES)) || 675 if ((S_ISDIR(i->stat.st_mode) && (file_type_ & DIRECTORIES)) ||
696 (!S_ISDIR(i->stat.st_mode) && (file_type_ & FILES))) 676 (!S_ISDIR(i->stat.st_mode) && (file_type_ & FILES)))
697 directory_entries_.push_back(*i); 677 directory_entries_.push_back(*i);
698 } 678 }
699 } 679 }
700 680
701 return root_path_.Append(directory_entries_[current_directory_entry_ 681 return root_path_.Append(directory_entries_[current_directory_entry_
702 ].filename); 682 ].filename);
703 } 683 }
704 684
685 void FileEnumerator::GetFindInfo(FindInfo* info) {
686 DCHECK(info);
687
688 if (current_directory_entry_ >= directory_entries_.size())
689 return;
690
691 DirectoryEntryInfo* cur_entry = &directory_entries_[current_directory_entry_];
692 memcpy(&(info->stat), &(cur_entry->stat), sizeof(info->stat));
693 info->filename.assign(cur_entry->filename.value());
694 }
695
696 bool FileEnumerator::IsDirectory(const FindInfo& info) {
697 return S_ISDIR(info.stat.st_mode);
698 }
699
700 // static
701 FilePath FileEnumerator::GetFilename(const FindInfo& find_info) {
702 return FilePath(find_info.filename);
703 }
704
705 bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries, 705 bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries,
706 const FilePath& source, bool show_links) { 706 const FilePath& source, bool show_links) {
707 base::ThreadRestrictions::AssertIOAllowed(); 707 base::ThreadRestrictions::AssertIOAllowed();
708 DIR* dir = opendir(source.value().c_str()); 708 DIR* dir = opendir(source.value().c_str());
709 if (!dir) 709 if (!dir)
710 return false; 710 return false;
711 711
712 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD) && \ 712 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD) && \
713 !defined(OS_OPENBSD) && !defined(OS_SOLARIS) 713 !defined(OS_OPENBSD) && !defined(OS_SOLARIS)
714 #error Port warning: depending on the definition of struct dirent, \ 714 #error Port warning: depending on the definition of struct dirent, \
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 if (HANDLE_EINTR(close(infile)) < 0) 881 if (HANDLE_EINTR(close(infile)) < 0)
882 result = false; 882 result = false;
883 if (HANDLE_EINTR(close(outfile)) < 0) 883 if (HANDLE_EINTR(close(outfile)) < 0)
884 result = false; 884 result = false;
885 885
886 return result; 886 return result;
887 } 887 }
888 #endif // defined(OS_MACOSX) 888 #endif // defined(OS_MACOSX)
889 889
890 } // namespace file_util 890 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.cc ('k') | base/file_util_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698