为什么 file.exists return FALSE 尽管在 list.files?

Why does file.exists return FALSE despite being in list.files?

我有一个文件 x 出现在目录中,list.files

证明了这一点
x <- "./data-raw/paths/calculate-route-by-FROM-TO/2017-05-2075--FROM-Flinders-Street-Railway-Station--Melbourne-Victoria-3004--VIC--TO-Melbourne-Sports-Aquatic-Centre--30-Aughtie-Dr--Melbourne-VIC-3206--VIC-csv"
x %in% list.files("./data-raw/paths", recursive = TRUE, full.names = TRUE)
# [1] TRUE
file.exists(x)
# [1] FALSE

请注意 x 缺少扩展名,但我在 ?file.exists 中找不到这样的警告:

file.exists returns a logical vector indicating whether the files named by its argument exist. (Here ‘exists’ is in the sense of the system's stat call: a file will be reported as existing only if you have the permissions needed by stat. Existence can also be checked by file.access, which might use different permissions and so obtain a different result. Note that the existence of a file does not imply that it is readable: for that use file.access.) What constitutes a ‘file’ is system-dependent, but should include directories. (However, directory names must not include a trailing backslash or slash on Windows.) Note that if the file is a symbolic link on a Unix-alike, the result indicates if the link points to an actual file, not just if the link exists. Lastly, note the different function exists which checks for existence of R objects.

文档中的唯一提示是访问限制可能导致 FALSE,实际上 file.access(x)-1,但我似乎可以访问该文件(以及其他非常相似的文件,没有那么受影响)。

Windows 对文件名的长度(260 个字符)有上限,x 超出了上限。缩短文件导致 file.exists 返回 TRUE