Example usage for org.apache.commons.net.ftp FTPCommand MFMT

List of usage examples for org.apache.commons.net.ftp FTPCommand MFMT

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPCommand MFMT.

Prototype

int MFMT

To view the source code for org.apache.commons.net.ftp FTPCommand MFMT.

Click Source Link

Usage

From source file:ch.cyberduck.core.ftp.FTPPath.java

private void writeModificationDateImpl(long created, long modified) throws IOException {
    this.getSession()
            .message(MessageFormat.format(Locale.localizedString("Changing timestamp of {0} to {1}", "Status"),
                    this.getName(), UserDateFormatterFactory.get().getShortFormat(modified)));

    final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter();
    if (this.getSession().getClient().isFeatureSupported(FTPCommand.MFMT)) {
        if (this.getSession().getClient().setModificationTime(this.getAbsolute(),
                formatter.format(modified, TimeZone.getTimeZone("UTC")))) {
            this.attributes().setModificationDate(modified);
        }//from   w  w  w .  j  a  va  2  s .  c o m
    } else {
        if (this.getSession().isUtimeSupported()) {
            // The utime() function sets the access and modification times of the named
            // file from the structures in the argument array timep.
            // The access time is set to the value of the first element,
            // and the modification time is set to the value of the second element
            // Accessed date, modified date, created date
            if (this.getSession().getClient()
                    .sendSiteCommand("UTIME " + this.getAbsolute() + " "
                            + formatter.format(new Date(modified), TimeZone.getTimeZone("UTC")) + " "
                            + formatter.format(new Date(modified), TimeZone.getTimeZone("UTC")) + " "
                            + formatter.format(new Date(created), TimeZone.getTimeZone("UTC")) + " UTC")) {
                this.attributes().setModificationDate(modified);
                this.attributes().setCreationDate(created);
            } else {
                this.getSession().setUtimeSupported(false);
                log.warn("UTIME not supported");
            }
        }

    }
}