Esempio n. 1
0
        public static string GetTemplatePath(string localPathRoot, TemplateName templateName)
        {
            if (!templateName.IsRooted)
            {
                return(Path.Combine(localPathRoot, templateName.Name));
            }

            return(Path.Combine(localPathRoot, templateName.Name.Substring(1)));
        }
Esempio n. 2
0
        /** <summary>
         * Load a template from dir or group file.  Group file is given
         * precedence over dir with same name. <paramref name="name"/> is
         * always fully qualified.
         * </summary>
         */
        protected override CompiledTemplate Load(string name)
        {
            if (Verbose)
            {
                Console.WriteLine("STGroupDir.load(" + name + ")");
            }

            string parent = Utility.GetParent(name); // must have parent; it's fully-qualified
            string prefix = Utility.GetPrefix(name);

            //      if (parent.isEmpty()) {
            //          // no need to check for a group file as name has no parent
            //            return loadTemplateFile("/", name+TemplateFileExtension); // load t.st file
            //      }

            if (!Path.IsPathRooted(parent))
            {
                throw new ArgumentException();
            }

            Uri groupFileURL;

            try
            {
                // see if parent of template name is a group file
                groupFileURL = new Uri(TemplateName.GetTemplatePath(root.LocalPath, parent) + GroupFileExtension);
            }
            catch (UriFormatException e)
            {
                ErrorManager.InternalError(null, "bad URL: " + TemplateName.GetTemplatePath(root.LocalPath, parent) + GroupFileExtension, e);
                return(null);
            }

            if (!File.Exists(groupFileURL.LocalPath))
            {
                string unqualifiedName = Path.GetFileName(name);
                return(LoadTemplateFile(prefix, unqualifiedName + TemplateFileExtension)); // load t.st file
            }
#if false
            InputStream @is = null;
            try
            {
                @is = groupFileURL.openStream();
            }
            catch (FileNotFoundException fnfe)
            {
                // must not be in a group file
                return(loadTemplateFile(parent, name + TemplateFileExtension)); // load t.st file
            }
            catch (IOException ioe)
            {
                errMgr.internalError(null, "can't load template file " + name, ioe);
            }

            try
            {
                // clean up
                if (@is != null)
                {
                    @is.close();
                }
            }
            catch (IOException ioe)
            {
                errMgr.internalError(null, "can't close template file stream " + name, ioe);
            }
#endif

            LoadGroupFile(prefix, groupFileURL.LocalPath);

            return(RawGetTemplate(name));
        }
Esempio n. 3
0
        public static string GetTemplatePath(string localPathRoot, TemplateName templateName)
        {
            if (!templateName.IsRooted)
                return Path.Combine(localPathRoot, templateName.Name);

            return Path.Combine(localPathRoot, templateName.Name.Substring(1));
        }