public static OloMatterDirectory Parse(string fileSystemPath)
        {
            OloMatter matter = OloMatter.Parse(fileSystemPath);

            // Trim down to just the directory
            if (Utilities.IsFile(fileSystemPath).Value)
            {
                fileSystemPath = Path.GetDirectoryName(fileSystemPath);
            }

            string afterMatter = fileSystemPath.Replace(matter.ToString(), "");

            while (afterMatter.EndsWith("\\") || afterMatter.EndsWith("/"))
            {
                afterMatter = afterMatter.TrimEnd('\\').TrimEnd('/');
            }

            if (afterMatter.IndexOf(Path.DirectorySeparatorChar) > 0)
            { // Has relative path
                return(new OloMatterDirectory()
                {
                    Matter = matter,
                    MatterRelativePath = Path.DirectorySeparatorChar + afterMatter.Substring(0, afterMatter.LastIndexOf(Path.DirectorySeparatorChar))
                });
            }
            else
            {
                return(new OloMatterDirectory()
                {
                    Matter = matter,
                    MatterRelativePath = ""
                });
            }
        }
Пример #2
0
        public static OloFile Parse(string fileSystemPath)
        {
            OloFile            file   = new OloFile();
            OloMatter          Matter = OloMatter.Parse(fileSystemPath);
            OloMatterDirectory Dir    = OloMatterDirectory.Parse(fileSystemPath);

            string afterMatter = fileSystemPath.Replace(Matter.ToString(), "");

            while (afterMatter.EndsWith("\\") || afterMatter.EndsWith("/"))
            {
                afterMatter = afterMatter.TrimEnd('\\').TrimEnd('/');
            }

            if (afterMatter.IndexOf(Path.DirectorySeparatorChar) > 0)
            { // Has relative path
                file.Title     = afterMatter.Substring(afterMatter.LastIndexOf(Path.DirectorySeparatorChar));
                file.Extension = file.Title.Substring(file.Title.LastIndexOf("."));
                file.Title     = file.Title.Substring(0, file.Title.LastIndexOf(".") - 1);
            }
            else
            {
                file.Extension = afterMatter.Substring(afterMatter.LastIndexOf("."));
                file.Title     = afterMatter.Substring(0, afterMatter.LastIndexOf(".") - 1);
            }

            return(file);
        }