Now retrieving the file's last modification date and sending it to the FTP client, I still need to figure out how to set the last modification date when a file is modified by the client though
This commit is contained in:
		
							parent
							
								
									3f77399538
								
							
						
					
					
						commit
						a3752b3f8c
					
				@ -824,18 +824,33 @@ class FTPServer : public TCPServer<T>
 | 
			
		||||
        if (currentDirectory)
 | 
			
		||||
        {
 | 
			
		||||
          currentDirectory.rewindDirectory();
 | 
			
		||||
          while (true) //Maybe be remove in the future to improve responsiveness
 | 
			
		||||
          while (true) //May be removed in the future to improve responsiveness
 | 
			
		||||
          {
 | 
			
		||||
            File fileOrDir = currentDirectory.openNextFile();
 | 
			
		||||
 | 
			
		||||
            if (!fileOrDir) //No more files in the directory
 | 
			
		||||
              break;
 | 
			
		||||
 | 
			
		||||
            #ifdef DEBUG_FTPS
 | 
			
		||||
            Serial.printf("Filename : %s\n", fileOrDir.name());
 | 
			
		||||
            #endif
 | 
			
		||||
            //We try to retrieve the last modification date
 | 
			
		||||
            const time_t fileModifDate = fileOrDir.getLastWrite();
 | 
			
		||||
            struct tm *timeP = localtime(&fileModifDate);
 | 
			
		||||
            //Buffer necessary to store the month's three letter abbreviation
 | 
			
		||||
            char month[4] = "";
 | 
			
		||||
            
 | 
			
		||||
            client->_dataClient.printf("%crwxrwxrwx 1 owner esp8266           %d Aug 26 16:31 %s\r\n", fileOrDir.isDirectory() ? 'd' : '-', fileOrDir.isDirectory() ? 0 : fileOrDir.size(), fileOrDir.name());
 | 
			
		||||
            #ifdef DEBUG_FTPS
 | 
			
		||||
            Serial.printf("Filename : %s, %s %d %d %d:%d\n", fileOrDir.name(), monthNumTo3LetterAbbreviation(month, timeP->tm_mon), timeP->tm_mon, timeP->tm_mday, timeP->tm_hour, timeP->tm_min);
 | 
			
		||||
            #endif
 | 
			
		||||
 | 
			
		||||
            char zero_prepended[3][3] = {"","",""};
 | 
			
		||||
            
 | 
			
		||||
            client->_dataClient.printf("%crwxrwxrwx 1 owner esp8266           %d %s %s %s:%s %s\r\n", 
 | 
			
		||||
            fileOrDir.isDirectory() ? 'd' : '-', 
 | 
			
		||||
            fileOrDir.isDirectory() ? 0 : fileOrDir.size(),
 | 
			
		||||
            monthNumTo3LetterAbreviation(month, timeP->tm_mon),
 | 
			
		||||
            dateTimeFormater(zero_prepended[0],timeP->tm_mday,'0'),
 | 
			
		||||
            dateTimeFormater(zero_prepended[1],timeP->tm_hour,'0'),
 | 
			
		||||
            dateTimeFormater(zero_prepended[2],timeP->tm_min,'0'),
 | 
			
		||||
            fileOrDir.name());
 | 
			
		||||
 | 
			
		||||
            fileOrDir.close();
 | 
			
		||||
          }
 | 
			
		||||
@ -849,10 +864,8 @@ class FTPServer : public TCPServer<T>
 | 
			
		||||
          #endif
 | 
			
		||||
          return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user