I need to process a video file, and I need the file to be completed before I open it. So I need to check if the file is opened or not before processing it, but opened by ano
Without any additional gems, a slightly wasteful way might be:
if %x[lsof -F n].split("\n").grep(/yourfilename/).empty?
# all clear
else
end
Or
if system %Q[lsof #{filename}]
# still open..
else
# all clear
end
Or, ignore my hacked suggestion and use a gem for this: https://github.com/jordansissel/fosl