| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ | 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ |
| 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ | 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 int64 size; // File size, in bytes. -1 if not applicable. | 26 int64 size; // File size, in bytes. -1 if not applicable. |
| 27 | 27 |
| 28 // Last modified time, in local time zone. | 28 // Last modified time, in local time zone. |
| 29 base::Time last_modified; | 29 base::Time last_modified; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class FtpDirectoryListingParser { | 32 class FtpDirectoryListingParser { |
| 33 public: | 33 public: |
| 34 virtual ~FtpDirectoryListingParser(); | 34 virtual ~FtpDirectoryListingParser(); |
| 35 | 35 |
| 36 virtual FtpServerType GetServerType() const = 0; |
| 37 |
| 36 // Adds |line| to the internal parsing buffer. Returns true on success. | 38 // Adds |line| to the internal parsing buffer. Returns true on success. |
| 37 virtual bool ConsumeLine(const string16& line) = 0; | 39 virtual bool ConsumeLine(const string16& line) = 0; |
| 38 | 40 |
| 39 // Returns true if there is at least one FtpDirectoryListingEntry available. | 41 // Returns true if there is at least one FtpDirectoryListingEntry available. |
| 40 virtual bool EntryAvailable() const = 0; | 42 virtual bool EntryAvailable() const = 0; |
| 41 | 43 |
| 42 // Returns the next entry. It is an error to call this function unless | 44 // Returns the next entry. It is an error to call this function unless |
| 43 // EntryAvailable returns true. | 45 // EntryAvailable returns true. |
| 44 virtual FtpDirectoryListingEntry PopEntry() = 0; | 46 virtual FtpDirectoryListingEntry PopEntry() = 0; |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 // Parser for "ls -l"-style directory listing. | 49 // Parser for "ls -l"-style directory listing. |
| 48 class FtpLsDirectoryListingParser : public FtpDirectoryListingParser { | 50 class FtpLsDirectoryListingParser : public FtpDirectoryListingParser { |
| 49 public: | 51 public: |
| 50 FtpLsDirectoryListingParser(); | 52 FtpLsDirectoryListingParser(); |
| 51 | 53 |
| 52 // FtpDirectoryListingParser methods: | 54 // FtpDirectoryListingParser methods: |
| 55 virtual FtpServerType GetServerType() const { return SERVER_LSL; } |
| 53 virtual bool ConsumeLine(const string16& line); | 56 virtual bool ConsumeLine(const string16& line); |
| 54 virtual bool EntryAvailable() const; | 57 virtual bool EntryAvailable() const; |
| 55 virtual FtpDirectoryListingEntry PopEntry(); | 58 virtual FtpDirectoryListingEntry PopEntry(); |
| 56 | 59 |
| 57 private: | 60 private: |
| 58 std::queue<FtpDirectoryListingEntry> entries_; | 61 std::queue<FtpDirectoryListingEntry> entries_; |
| 59 | 62 |
| 60 DISALLOW_COPY_AND_ASSIGN(FtpLsDirectoryListingParser); | 63 DISALLOW_COPY_AND_ASSIGN(FtpLsDirectoryListingParser); |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 // Parser for VMS-style directory listing (including variants). | 66 // Parser for VMS-style directory listing (including variants). |
| 64 class FtpVmsDirectoryListingParser : public FtpDirectoryListingParser { | 67 class FtpVmsDirectoryListingParser : public FtpDirectoryListingParser { |
| 65 public: | 68 public: |
| 66 FtpVmsDirectoryListingParser(); | 69 FtpVmsDirectoryListingParser(); |
| 67 | 70 |
| 68 // FtpDirectoryListingParser methods: | 71 // FtpDirectoryListingParser methods: |
| 72 virtual FtpServerType GetServerType() const { return SERVER_VMS; } |
| 69 virtual bool ConsumeLine(const string16& line); | 73 virtual bool ConsumeLine(const string16& line); |
| 70 virtual bool EntryAvailable() const; | 74 virtual bool EntryAvailable() const; |
| 71 virtual FtpDirectoryListingEntry PopEntry(); | 75 virtual FtpDirectoryListingEntry PopEntry(); |
| 72 | 76 |
| 73 private: | 77 private: |
| 74 // Consumes listing line which is expected to be a directory listing entry | 78 // Consumes listing line which is expected to be a directory listing entry |
| 75 // (and not a comment etc). Returns true on success. | 79 // (and not a comment etc). Returns true on success. |
| 76 bool ConsumeEntryLine(const string16& line); | 80 bool ConsumeEntryLine(const string16& line); |
| 77 | 81 |
| 78 enum State { | 82 enum State { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 100 bool last_is_directory_; | 104 bool last_is_directory_; |
| 101 | 105 |
| 102 std::queue<FtpDirectoryListingEntry> entries_; | 106 std::queue<FtpDirectoryListingEntry> entries_; |
| 103 | 107 |
| 104 DISALLOW_COPY_AND_ASSIGN(FtpVmsDirectoryListingParser); | 108 DISALLOW_COPY_AND_ASSIGN(FtpVmsDirectoryListingParser); |
| 105 }; | 109 }; |
| 106 | 110 |
| 107 } // namespace net | 111 } // namespace net |
| 108 | 112 |
| 109 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ | 113 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ |
| OLD | NEW |