Chris Rackauckas
Chris Rackauckas

Reputation: 19132

Checking if a folder exists

I am looking for a good way of checking whether a folder exists from within a Julia script. For now what I am doing is:

function dir_exists(dir)
  exists = true
  try
    readdir(dir)
  catch err
    exists = false
  end
  exists
end

but I was wonder if there's a way that doesn't rely on exception handling.

Upvotes: 16

Views: 6288

Answers (1)

Warren
Warren

Reputation: 367

The function is you are looking for is isdir.

Upvotes: 25

Related Questions