コード例 #1
0
        public void addFolder(String path, String name, String vpath, FileTypes type)
        {
            path = path.Replace(base_path, "root");
            VFolder parent = getFolderFromPath(Path.GetDirectoryName(path));

            parent.folders.Add(new VFolder(name, path + Path.DirectorySeparatorChar + name, vpath, type));
        }
コード例 #2
0
        public Template(String path, String inpath, String outpath)
        {
            tmpdata = File.ReadAllText(path);

            base_path = inpath;
            out_path  = outpath;
            root      = new VFolder("root", out_path, "root", FileTypes.Folder);
        }
コード例 #3
0
 public VFile(String _name, String _content, VFolder _parent, String _path, String _vpath, FileTypes _type)
 {
     name    = _name;
     content = _content;
     parent  = _parent;
     path    = _path;
     vpath   = _vpath;
     type    = _type;
 }
コード例 #4
0
        public String addFile(String _htmdata, String path, String vpath, FileTypes type)
        {
            path = path.Replace(base_path, "root");
            String cplate = tmpdata.Replace("{{content}}", _htmdata);

            log.info($"Adding file {path} to directory {Path.GetDirectoryName(path)}");
            VFolder parent = getFolderFromPath(Path.GetDirectoryName(path));

            parent.file.Add(new VFile(Path.GetFileName(path), cplate, parent, path, vpath, type));
            return(cplate);
        }
コード例 #5
0
        public VFile getVFileFromPath(String path)
        {
            VFolder folder = getFolderFromPath(Path.GetDirectoryName(path));

            foreach (VFile f in folder.file)
            {
                if (Path.GetFileName(f.vpath) == Path.GetFileName(path))
                {
                    return(f);
                }
            }
            throw new FileNotFoundException($"Cannot find file {path}");
        }
コード例 #6
0
 private void recursiveRender(VFolder bfol, String title)
 {
     foreach (VFolder f in bfol.folders)
     {
         log.info($"Scanning folder {f.path}");
         Directory.CreateDirectory(f.path.Replace("root", out_path));
         recursiveRender(f, title);
     }
     foreach (VFile d in bfol.file)
     {
         log.info($"Rendering file {d.path.Replace("root",out_path)+".html"}");
         File.WriteAllText(d.path.Replace("root", out_path) + ".html", d.content.Replace("{{title}}", title));
     }
 }
コード例 #7
0
 private VFolder getVFolderRecursive(List <String> pathbits, VFolder searchf)
 {
     foreach (VFolder i in searchf.folders)
     {
         if (Path.GetFileName(i.vpath) == pathbits[0])
         {
             pathbits.RemoveAt(0);
             if (pathbits.Count < 1)
             {
                 return(i);
             }
             return(getVFolderRecursive(pathbits, i));
         }
     }
     return(searchf);
 }
コード例 #8
0
 private VFolder getFolderRecursive(List <String> pathbits, VFolder searchf)
 {
     foreach (VFolder i in searchf.folders)
     {
         if (i.name == pathbits[0])
         {
             pathbits.RemoveAt(0);
             if (pathbits.Count < 1)
             {
                 return(i);
             }
             return(getFolderRecursive(pathbits, i));
         }
     }
     throw new FileNotFoundException($"Cannot find folder ");
 }