05-29-2011, 09:27 AM
Is there a way to check if a file exists without having to know the file extension?
I'm trying to check if a sound effect specified in a setting exists, but I really don't want to have to create a conditional like this: /lazy
I'm trying to check if a sound effect specified in a setting exists, but I really don't want to have to create a conditional like this: /lazy
Code:
if File.exist?('Audio/SE/'+setting+'.ogg') or File.exist?('Audio/SE/'+setting+'.wav') or File.exist?('Audio/SE/'+setting+'.mp3') or File.exist?('Audio/SE/'+setting+'.mid') or File.exist?('Audio/SE/'+setting+'.wma')
# Something happens
end