0
votes

Apparently there are some aspects in implementing an FTP server which are left as an exercise to the reader of the RFC (959). (Like the response to the LIST command.) This amounts to trying to figure out the general consensus among other implementations, and doing that.

Since there is no explicit command to move files from one directory to another, I've found that this is generally done with the rename commands (RNFR, RNTO). For example, in WinSCP, if you drag a file from /data/dir/file to the parent directory (..), it does

RNFR /data/dir/file
RNTO /data/file

Are there any clients in the wild that use relative paths in the wild? For example, if the current working directory is /data/dir, are there any clients that would do this?

RNFR file
RNTO ../file

Or is it common practice for servers to understand renames with relative paths from command line clients?

1
FYI, the directory listing format was standardized by the MLSD and MLST commands in RFC 3659.Remy Lebeau
@RemyLebeau, good to know, thanks. I was referring to the LIST command, though - question edited to clarify.cp.engr
Yes, LIST has no standardized format, which is why MLSD/MLST were created to solve that.Remy Lebeau

1 Answers

1
votes

The RNFR and RNTO are explicit commands to move files from one directory to another.

So you can use them to move files between directories. On *nix operating systems the rename and move is the same operation (at least as long as you stay with the same file system).

Both commands take pathname as an argument, just as most other FTP commands (e.g. CWD, DELE).

RNFR <SP> <pathname> <CRLF>
RNTO <SP> <pathname> <CRLF>

Regarding pathname, the RFC 959 says in section 4.1.3:

The syntax of pathnames must conform to server site conventions (with standard defaults applicable)

I believe that this means you can reasonably expect the servers to understand the .. in RNTO, just as the servers do understand CWD ..


If there are any (GUI?) clients that make use of this? I wouldn't say so. Why would the client bother to try to find a common root of the move operation and calculate the relative path, if it can just simply use an absolute path?


As @Remy commented already, the directory listing format was standardized by the MLSD and MLST commands in RFC 3659.

Most modern FTP servers do support these, with notable exception of IIS FTP (what cannot be called modern FTP server anyway).