Commit 2051757c by Craig Heffner

Updated to use XDG base directory specification

parent a442dc7e
......@@ -20,7 +20,7 @@ class Settings:
VERSION = "2.1.2b"
# Sub directories
BINWALK_USER_DIR = ".binwalk"
BINWALK_USER_DIR = "binwalk"
BINWALK_MAGIC_DIR = "magic"
BINWALK_CONFIG_DIR = "config"
BINWALK_PLUGINS_DIR = "plugins"
......@@ -35,7 +35,7 @@ class Settings:
Class constructor. Enumerates file paths and populates self.paths.
'''
# Path to the user binwalk directory
self.user_dir = self._get_user_dir()
self.user_dir = self._get_user_config_dir()
# Path to the system wide binwalk directory
self.system_dir = common.get_module_path()
......@@ -107,6 +107,16 @@ class Settings:
return fpath
def _get_user_config_dir(self):
try:
xdg_path = os.getenv('XDG_CONFIG_HOME')
if xdg_path is not None:
return xdg_path
except Exception:
pass
return os.path.join(self._get_user_dir(), '.config')
def _get_user_dir(self):
'''
Get the user's home directory.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment