Let's say I just created this directory and file:
dir.create("foo")
cat("bar", file="bar")
#both files exist:
file.exists("foo")
file.exists("bar")
I want to test both foo and bar to test logically if they are directories or not. If something is a directory I want to be able to put other files in it. If the item is not a directory I want to use stop
but don't know of how test.
Poking around a bit got me to:
file.info("foo", "bar")
.Internal(file.info(fn <- c("foo", "bar")))
Which both give me the info I'm after but the .Internal
use seems to be using a logical test of sorts for directory (meaning more efficient), but I can't figure out how. What is file.info
using to test if the object is a directory?
Maybe you want file_test
?
file_test("-d", c("foo", "bar"))
# [1] TRUE FALSE
file.info
is obviously platform dependent and uses _wstati64
on Windows and stat
on Linux. See https://svn.r-project.org/R/trunk/src/main/platform.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With