Exemplo n.º 1
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;
        }
Exemplo n.º 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);
        }