# HG changeset patch # User Matthew Wild # Date 1302009085 -3600 # Node ID 69fe5fd861e7dfa5c458578c8acd47992fe5fc9a # Parent 6b0d7d94eb7f95dcd3b17c97e71cc44e531cf6a7 tools/migration: Support for ~/ in paths diff -r 6b0d7d94eb7f -r 69fe5fd861e7 tools/migration/migrator/prosody_files.lua --- 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 }); diff -r 6b0d7d94eb7f -r 69fe5fd861e7 tools/migration/prosody-migrator.lua --- 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