Hello,
So I am working with Ruby, and...
I have an error "ERRNO::EEXIST, text
line 2 ... File exists"
The error occurs if a directory it created (defined in EGGPATH) already exists, which should work in itself because of "unless File.exist?(EGGPATH)"
While what I'm trying to do is:
def cyhm #file text
Dir.mkdir(EGGPATH) unless File.exist?(EGGPATH)
File.open(EGGPATH + "/CAN YOU HEAR ME.txt", "w+") do |f|
f.write("text")
end
end
def cyhm_pt2
Dir.mkdir(EGGPATH) unless File.exist?(EGGPATH)
if File.exists?(EGGPATH + "/CAN YOU HEAR ME.txt") == false
cyhm
end
File.open(EGGPATH + "/CAN YOU HEAR ME.txt", "a+") do |f|
f.write("text2")
end
end
While EGGPATH is defined here, in the other file:
TXTLIST = ["Ą", "ą", "Ć", "ć", "Ę", "ę", "Ł", "ł", "Ń", "ń", "Ó", "ó", "Ś", "ś", "Ź", "ź", "Ż", "ż"] #file randomtxt
EGGPAT = TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)] + TXTLIST[rand(TXTLIST.size)]
if File.exists?(SAVEPATH + "\\MODAR\\eseggdir.es") == false
File.open(SAVEPATH + "\\MODAR\\eseggdir.es", "w+") do |f|
f.write(EGGPAT)
end
end
EGGPATH = File.read(SAVEPATH + "\\MODAR\\eseggdir.es")
Also, don't tell me to switch to a newer version of Ruby, cause I'm working with RPGXP, and I don't want to change it anytime soon...
What I have tried:
I haven't tried anything, sorry, because as far as I know (which isn't very much) everything should work fine.