Sha256: 52fc80b6a60ce4504ad101966f20b34fc967905e857058ce5fc60a301cba5f8d
Contents?: true
Size: 966 Bytes
Versions: 12
Compression:
Stored size: 966 Bytes
Contents
class Pathname def non_existing dir = dirname ext = extname name = basename(ext) postfix = nil while (path = dir + "#{name}#{postfix}#{ext}").exist? postfix = postfix ? postfix.succ : '-a' end path # begin # FSPath('abc').open(Fcntl::O_WRONLY | Fcntl::O_CREAT | Fcntl::O_EXCL) do |f| # end # rescue => e # p e # end end def lock(options = {}, &block) File.lock(@path, options, &block) # class File # def self.lock(path, options = {}) # if lock = File.open(path, options[:mode] || 'r') # begin # if lock.flock(options[:no_block] ? (File::LOCK_EX | File::LOCK_NB) : (File::LOCK_EX)) # yield # end # ensure # lock.flock(File::LOCK_UN) # lock.close # end # end # end # end # Fcntl::O_RDONLY | Fcntl::O_CREAT # Fcntl::O_SHLOCK # Fcntl::O_EXLOCK end end
Version data entries
12 entries across 12 versions & 1 rubygems