Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module RTP
- def self.loadOtherGameDir(dir,title)
- title=title.gsub(/[^\w ]/,"_")
- newdir=dir.gsub(/[\/\\]$/,"")+"/"
- # Convert to UTF-8 because of ANSI function
- newdir+=getUnicodeStringFromAnsi(title)
- ret=safeIsDirectory?(newdir) ? newdir : dir
- return ret
- end
- def self.getOtherSaveFileName(fileName,title)
- return getOtherSaveFolder(title).gsub(/[\/\\]$/,"")+"/"+fileName
- end
- def self.getOtherSaveFolder(title)
- # XXX: Use "." instead of Dir.pwd because of problems retrieving files if
- # the current directory contains an accent mark
- pwd="."
- # Get the known folder path for saved games
- savedGames=getKnownFolder([
- 0x4c5c32ff,0xbb9d,0x43b0,0xb5,0xb4,0x2d,0x72,0xe5,0x4e,0xaa,0xa4])
- if savedGames && savedGames!="" && isDirWritable(savedGames)
- pwd=loadOtherGameDir(savedGames,title)
- end
- if isDirWritable(pwd)
- folder=pwd
- else
- appdata=ENV["LOCALAPPDATA"]
- if isDirWritable(appdata)
- appdata=loadOtherGameDir(appdata,title)
- else
- appdata=ENV["APPDATA"]
- if isDirWritable(appdata)
- appdata=loadOtherGameDir(appdata,title)
- elsif isDirWritable(pwd)
- appdata=pwd
- else
- appdata="."
- end
- end
- folder=appdata
- end
- return folder
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement