Exemplo n.º 1
0
        private string GetUserDir0(string key)
        {
            string userDir  = HostSystem.Combine(PathToUsersDir, key);
            string luserDir = HostSystem.ToRelativePath(userDir, RuntimeDirectory);

            if (HostSystem.DirExists(luserDir))
            {
                return(luserDir);
            }
            string k1 = key.Replace("_", " ");

            foreach (string fsn in HostSystem.GetDirectories(PathToUsersDir))
            {
                string s = fsn;
                if (fsn.StartsWith(PathToUsersDir))
                {
                    s = s.Substring(PathToUsersDir.Length);
                }
                if (s.StartsWith("/"))
                {
                    s = s.Substring(1);
                }
                if (s.StartsWith("\\"))
                {
                    s = s.Substring(1);
                }
                string s1 = "^" + s.Replace(".", "\\.").Replace("~", ".*").
                            Replace("~", ".*").Replace("_", "\\b").
                            Replace("\\b\\b", "\\b") + "$";

                Regex regex;
                try
                {
                    regex = new Regex(s1);
                }
                catch (Exception e)
                {
                    writeToLog("new Regex '" + s1 + "' " + e);
                    continue;
                }
                if (regex.IsMatch(k1))
                {
                    luserDir = HostSystem.ToRelativePath(fsn, RuntimeDirectory);
                    if (HostSystem.DirExists(luserDir))
                    {
                        return(luserDir);
                    }
                    return(fsn);
                }
            }
            return(luserDir);
        }
Exemplo n.º 2
0
        private string ToPath(string path, out string prefix)
        {
            if (path == null)
            {
                prefix = null;
                return(null);
            }
            string realPath = HostSystem.FirstExisting(path, RuntimeDirectories, out prefix);

            if (realPath != null)
            {
                return(realPath);
            }
            return(HostSystem.Combine(prefix, path));
        }