Telcrome
Telcrome

Reputation: 369

How to determine if a filesystem path is already taken in Julia

For files there is isfile, but what if I dont know if the path is taken up by a file or a directory?

Basically, is there a function in Julia Base that does the following:

function is_in_use(path)::Bool
    return isfile(path) || isdir(path)
end

Maybe there are more cases that can use a path that I did not think of, but I hope you get the idea.

Upvotes: 4

Views: 226

Answers (1)

kabanus
kabanus

Reputation: 25895

Like this:

Base.Filesystem.ispath — Function

ispath(path) -> Bool

Return true if a valid filesystem entity exists at path, otherwise returns false. This is the generalization of isfile, isdir etc.

Upvotes: 4

Related Questions