mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Simplify careful_delete even more by relying on user:// on each OS
Closes #83.
This commit is contained in:
parent
3211cd0481
commit
ffadebb0df
1 changed files with 2 additions and 10 deletions
|
@ -86,23 +86,15 @@ func parse_args():
|
||||||
return arguments
|
return arguments
|
||||||
|
|
||||||
func careful_delete(path_inside):
|
func careful_delete(path_inside):
|
||||||
var expected_prefix
|
var expected_prefix = "%s/tmp/" % OS.get_user_data_dir()
|
||||||
|
|
||||||
var os = OS.get_name()
|
var os = OS.get_name()
|
||||||
|
if os == "Windows":
|
||||||
if os == "X11":
|
|
||||||
expected_prefix = "%s/.local/share/Oh My Git/tmp/" % OS.get_environment("HOME")
|
|
||||||
elif os == "OSX":
|
|
||||||
expected_prefix = "%s/Library/Application Support/Oh My Git/tmp/" % OS.get_environment("HOME")
|
|
||||||
elif os == "Windows":
|
|
||||||
expected_prefix = "%s/AppData/Roaming/Oh My Git/tmp/" % OS.get_environment("USERPROFILE")
|
|
||||||
# In the game, we use forward slashes:
|
# In the game, we use forward slashes:
|
||||||
expected_prefix = expected_prefix.replace("\\", "/")
|
expected_prefix = expected_prefix.replace("\\", "/")
|
||||||
# Windows treats paths case-insensitively:
|
# Windows treats paths case-insensitively:
|
||||||
expected_prefix = expected_prefix.to_lower()
|
expected_prefix = expected_prefix.to_lower()
|
||||||
path_inside = path_inside.to_lower()
|
path_inside = path_inside.to_lower()
|
||||||
else:
|
|
||||||
helpers.crash("Unsupported OS: %s" % os)
|
|
||||||
|
|
||||||
if path_inside.substr(0,expected_prefix.length()) != expected_prefix:
|
if path_inside.substr(0,expected_prefix.length()) != expected_prefix:
|
||||||
helpers.crash("Refusing to delete directory %s that does not start with %s" % [path_inside, expected_prefix])
|
helpers.crash("Refusing to delete directory %s that does not start with %s" % [path_inside, expected_prefix])
|
||||||
|
|
Loading…
Reference in a new issue