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

Unified Diff: net/ftp/ftp_directory_listing_parsers.h

Issue 348036: Implement VMS FTP directory listing parser. (Closed)
Patch Set: fix Created 11 years, 1 month 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 | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parsers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parsers.h
diff --git a/net/ftp/ftp_directory_listing_parsers.h b/net/ftp/ftp_directory_listing_parsers.h
index 2f402e7d94c91c0a7e8a8ac16081605b6c83e5cf..230c641814d9ec7c7a4af9086121377bae53f8c6 100644
--- a/net/ftp/ftp_directory_listing_parsers.h
+++ b/net/ftp/ftp_directory_listing_parsers.h
@@ -13,18 +13,18 @@
#include "net/ftp/ftp_server_type_histograms.h"
namespace net {
-
+
struct FtpDirectoryListingEntry {
enum Type {
FILE,
DIRECTORY,
SYMLINK,
};
-
+
Type type;
string16 name;
int64 size; // File size, in bytes. -1 if not applicable.
-
+
// Last modified time, in local time zone.
base::Time last_modified;
};
@@ -32,33 +32,78 @@ struct FtpDirectoryListingEntry {
class FtpDirectoryListingParser {
public:
virtual ~FtpDirectoryListingParser();
-
+
// Adds |line| to the internal parsing buffer. Returns true on success.
virtual bool ConsumeLine(const string16& line) = 0;
-
+
// Returns true if there is at least one FtpDirectoryListingEntry available.
virtual bool EntryAvailable() const = 0;
-
+
// Returns the next entry. It is an error to call this function unless
// EntryAvailable returns true.
virtual FtpDirectoryListingEntry PopEntry() = 0;
};
-
+
+// Parser for "ls -l"-style directory listing.
class FtpLsDirectoryListingParser : public FtpDirectoryListingParser {
public:
FtpLsDirectoryListingParser();
-
+
// FtpDirectoryListingParser methods:
virtual bool ConsumeLine(const string16& line);
virtual bool EntryAvailable() const;
virtual FtpDirectoryListingEntry PopEntry();
-
+
private:
std::queue<FtpDirectoryListingEntry> entries_;
-
+
DISALLOW_COPY_AND_ASSIGN(FtpLsDirectoryListingParser);
};
-
+
+// Parser for VMS-style directory listing (including variants).
+class FtpVmsDirectoryListingParser : public FtpDirectoryListingParser {
+ public:
+ FtpVmsDirectoryListingParser();
+
+ // FtpDirectoryListingParser methods:
+ virtual bool ConsumeLine(const string16& line);
+ virtual bool EntryAvailable() const;
+ virtual FtpDirectoryListingEntry PopEntry();
+
+ private:
+ // Consumes listing line which is expected to be a directory listing entry
+ // (and not a comment etc). Returns true on success.
+ bool ConsumeEntryLine(const string16& line);
+
+ enum State {
+ STATE_INITIAL,
+
+ // Indicates that we have received the header, like this:
+ // Directory SYS$SYSDEVICE:[ANONYMOUS]
+ STATE_RECEIVED_HEADER,
+
+ // Indicates that we have received the first listing entry, like this:
+ // MADGOAT.DIR;1 2 9-MAY-2001 22:23:44.85
+ STATE_ENTRIES,
+
+ // Indicates that we have received the last listing entry.
+ STATE_RECEIVED_LAST_ENTRY,
+
+ // Indicates that we have successfully received all parts of the listing.
+ STATE_END,
+ } state_;
+
+ // VMS can use two physical lines if the filename is long. The first line will
+ // contain the filename, and the second line everything else. Store the
+ // filename until we receive the next line.
+ string16 last_filename_;
+ bool last_is_directory_;
+
+ std::queue<FtpDirectoryListingEntry> entries_;
+
+ DISALLOW_COPY_AND_ASSIGN(FtpVmsDirectoryListingParser);
+};
+
} // namespace net
#endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parsers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698