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)); }
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); }
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; }
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); }
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}"); }
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)); } }
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); }
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 "); }