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

Unified Diff: net/base/directory_lister.h

Issue 3175023: Allow net::DirectoryLister to be used to recursively list the directory, and ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/slideshow_ui.cc ('k') | net/base/directory_lister.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/directory_lister.h
===================================================================
--- net/base/directory_lister.h (revision 56913)
+++ net/base/directory_lister.h (working copy)
@@ -6,11 +6,14 @@
#define NET_BASE_DIRECTORY_LISTER_H_
#pragma once
+#include <vector>
+
#include "base/cancellation_flag.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/platform_thread.h"
#include "base/ref_counted.h"
+#include "base/task.h"
class MessageLoop;
@@ -26,27 +29,42 @@
class DirectoryLister : public base::RefCountedThreadSafe<DirectoryLister>,
public PlatformThread::Delegate {
public:
+ // Represents one file found.
+ struct DirectoryListerData {
+ file_util::FileEnumerator::FindInfo info;
+ FilePath path;
+ };
+
// Implement this class to receive directory entries.
class DirectoryListerDelegate {
public:
- virtual void OnListFile(
- const file_util::FileEnumerator::FindInfo& data) = 0;
+ // Called for each file found by the lister.
+ virtual void OnListFile(const DirectoryListerData& data) = 0;
+
+ // Called when the listing is complete.
virtual void OnListDone(int error) = 0;
protected:
virtual ~DirectoryListerDelegate() {}
};
+ // Sort options
+ // ALPHA_DIRS_FIRST is the default sort :
+ // directories first in name order, then files by name order
+ // FULL_PATH sorts by paths as strings, ignoring files v. directories
+ // DATE sorts by last modified date
enum SORT_TYPE {
- DEFAULT,
+ NO_SORT,
DATE,
- ALPHA
+ ALPHA_DIRS_FIRST,
+ FULL_PATH
};
DirectoryLister(const FilePath& dir,
DirectoryListerDelegate* delegate);
DirectoryLister(const FilePath& dir,
+ bool recursive,
SORT_TYPE sort,
DirectoryListerDelegate* delegate);
@@ -70,13 +88,21 @@
friend class base::RefCountedThreadSafe<DirectoryLister>;
friend class DirectoryDataEvent;
+ // Comparison methods for sorting, chosen based on |sort_|.
+ static bool CompareAlphaDirsFirst(const DirectoryListerData& a,
+ const DirectoryListerData& b);
+ static bool CompareDate(const DirectoryListerData& a,
+ const DirectoryListerData& b);
+ static bool CompareFullPath(const DirectoryListerData& a,
+ const DirectoryListerData& b);
+
~DirectoryLister();
- void OnReceivedData(const file_util::FileEnumerator::FindInfo* data,
- int count);
+ void OnReceivedData(const DirectoryListerData* data, int count);
void OnDone(int error);
FilePath dir_;
+ bool recursive_;
DirectoryListerDelegate* delegate_;
SORT_TYPE sort_;
MessageLoop* message_loop_;
« no previous file with comments | « chrome/browser/dom_ui/slideshow_ui.cc ('k') | net/base/directory_lister.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698