- #!/usr/bin/ruby
- begin
- directory_name = Dir::pwd + "/" + "test"
- if FileTest::directory?(directory_name)
- return
- end
- Dir::mkdir(directory_name)
- end
Above codes allow me to create a directory.
1 line expresses that this file is ruby process.
2 line is Main thread starting sign, 8 line is end sign.
4 line checks to exists or not.
7 line real make directory.
 


6 comments:
This is great but leads to a race condition. I would recommend wrapping the mkdir in a try/catch block
begin
Dir::mkdir(directory_name)
rescue
puts "the directory already exists"
end
I know this is an older post, but I have been using:
Dir::mkdir(directory) unless File.exists?(directory)
I used something very similar to what you're doing, Ryan C. Moon.
Yea. the Dir::mkdir comment works like a champ
Your mode of telling the whole thing in this piece of
writing is really good, every one be capable of effortlessly understand it, Thanks a lot.
Also visit my homepage - updated blog post
It can take pictures in a burst mode of up to nine times better
than on the fleshlight original iPad.
You might decide to take the most advantage of
this career choice, contacting insurance companies is absolutely essential.
If you've recently purchased a fleshlight adult toy or are thinking about it, or stray away from that sort of activity.
Post a Comment