FtpDataFileList.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * FtpDataFileList.h
8  *
9  ****/
10 
11 #pragma once
12 
13 #include "FtpDataStream.h"
14 #include "FileSystem.h"
15 
17 {
18 public:
19  explicit FtpDataFileList(FtpServerConnection& connection) : FtpDataStream(connection)
20  {
21  }
22 
23  void transferData(TcpConnectionEvent sourceEvent) override
24  {
25  if(completed) {
26  return;
27  }
28  Vector<String> list = fileList();
29  debug_d("send file list: %d", list.count());
30  for(unsigned i = 0; i < list.count(); i++) {
31  String s = F("01-01-15 01:00AM ");
32  s += fileGetSize(list[i]);
33  s += ' ';
34  s += list[i];
35  s += "\r\n";
36  writeString(s);
37  }
38  completed = true;
40  }
41 };
Definition: FtpDataStream.h:16
The String class.
Definition: WString.h:136
unsigned int count() const override
Definition: WVector.h:105
TcpConnectionEvent
Definition: TcpConnection.h:25
#define F(string_literal)
Wrap a string literal stored in flash and access it using a String object.
Definition: WString.h:113
#define debug_d
Definition: debug_progmem.h:100
void finishTransfer()
Definition: FtpDataStream.h:40
FtpDataFileList(FtpServerConnection &connection)
Definition: FtpDataFileList.h:19
Vector< String > fileList()
Get list of files on file system.
bool completed
Definition: FtpDataStream.h:74
Definition: FtpServerConnection.h:25
void transferData(TcpConnectionEvent sourceEvent) override
Definition: FtpDataFileList.h:23
Definition: FtpDataFileList.h:16
int writeString(const char *data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
Writes string data directly to the TCP buffer.
Definition: TcpConnection.h:63
uint32_t fileGetSize(const String &fileName)
Get size of file.