How to check if a given directory exists in Ruby

后端 未结 5 1568
难免孤独
难免孤独 2020-12-22 20:17

I am trying to write a script which automatically checks out or updates a Subversion URL based on whether a specified directory exists or not.

For some reason, my co

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 20:56

    You could use Kernel#test:

    test ?d, 'some directory'
    

    it gets it's origins from https://ss64.com/bash/test.html you will notice bash test has this flag -d to test if a directory exists -d file True if file is a Directory. [[ -d demofile ]]

提交回复
热议问题