33

Is there a simple way in Julia to check whether a file in the current working directory exists (something like test = os.path.isfile("foo.txt") in Python or inquire(file = "foo.txt", exist = test) in Fortran)?

Benjamin
  • 690
  • 1
  • 7
  • 14

1 Answers1

59

Julia has the isfile() function to test for a regular file:

julia> isfile("foo.txt")
false

shell> touch foo.txt

julia> isfile("foo.txt")
true

As the documentation:

Returns true if path (the parameter) is a regular file, false otherwise.

Evgeny
  • 4,173
  • 2
  • 19
  • 39
Gomiero
  • 2,240
  • 2
  • 22
  • 18