Software /
code /
prosody
Changeset
4239:69fe5fd861e7
tools/migration: Support for ~/ in paths
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 05 Apr 2011 14:11:25 +0100 |
parents | 4237:6b0d7d94eb7f |
children | 4240:b3d9063aad4d |
files | tools/migration/migrator/prosody_files.lua tools/migration/prosody-migrator.lua |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/migration/migrator/prosody_files.lua Tue Apr 05 13:26:19 2011 +0100 +++ b/tools/migration/migrator/prosody_files.lua Tue Apr 05 14:11:25 2011 +0100 @@ -22,7 +22,7 @@ local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end local function is_file(path) return lfs.attributes(path, "mode") == "file"; end local function clean_path(path) - return path:gsub("\\", "/"):gsub("//+", "/"); + return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os.getenv("HOME") or "~"); end local encode, decode; do local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end });
--- a/tools/migration/prosody-migrator.lua Tue Apr 05 13:26:19 2011 +0100 +++ b/tools/migration/prosody-migrator.lua Tue Apr 05 14:11:25 2011 +0100 @@ -3,6 +3,15 @@ CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR"); CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); +-- Substitute ~ with path to home directory in paths +if CFG_CONFIGDIR then + CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME")); +end + +if CFG_SOURCEDIR then + CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME")); +end + local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; -- Command-line parsing