Function: file-remote-p

Test whether FILE specifies a location on a remote system.
A file is considered remote if accessing it is likely to
be slower or less reliable than accessing local files.

`file-remote-p' never opens a new remote connection. It can
only reuse a connection that is already open.

Return nil or a string identifying the remote connection
(ideally a prefix of FILE). Return nil if FILE is a relative
file name.

When IDENTIFICATION is nil, the returned string is a complete
remote identifier: with components method, user, and host. The
components are those present in FILE, with defaults filled in for
any that are missing.

IDENTIFICATION can specify which part of the identification to
return. IDENTIFICATION can be the symbol `method', `user',
`host', or `localname'. Any other value is handled like nil and
means to return the complete identification. The string returned
for IDENTIFICATION `localname' can differ depending on whether
there is an existing connection.

If CONNECTED is non-nil, return an identification only if FILE is
located on a remote system and a connection is established to
that remote system.

Tip: You can use this expansion of remote identifier components
to derive a new remote file name from an existing one. For
example, if FILE is "/sudo::/path/to/file" then

(concat (file-remote-p FILE) "/bin/sh")

returns a remote file name for file "/bin/sh" that has the same remote identifier as FILE but expanded; a name such as "/sudo:root@myhost:/bin/sh".