string ReplaceIncludeDirectiveWithFileContents(string source, FolderExisting folder) { while (true) { var start = source.IndexOf("[include"); if (start != -1) { var fileNameStart = start + "[include".Length + 1; var end = source.IndexOf("]", fileNameStart); if (end != -1) { var fileName = source.Substring(fileNameStart, end - fileNameStart).Trim(); source = source.Substring(0, start) + GetIncludeFileContents(fileName, folder) + source.Substring(end + 1); } } else { break; } } return(source); }
string GetIncludeFileContents(string virtualPath, FolderExisting folder) { var file = FileSystem.FindFile(virtualPath, folder); var source = file.ReadAllText(); source = AddLineMarkers(source, file); source = ReplaceIncludeDirectiveWithFileContents(source, FileSystem.GetFolder(file)); return(source); }
public bool FileExists(string virtualPath, FolderExisting startSearchInFolder) { var realPath = CombineDirectory(rootResourceDirectoryPath, startSearchInFolder.VirtualPath, virtualPath); if (System.IO.File.Exists(realPath)) { return(true); } else { if (System.IO.File.Exists(realPath)) { return(true); } } return(false); }
public FileExisting FindFile(string virtualPath, FolderExisting startSearchInFolder) { var realPath = CombineDirectory(rootResourceDirectoryPath, startSearchInFolder.VirtualPath, virtualPath); if (System.IO.File.Exists(realPath)) { return(new FileExisting(this, CombineDirectory(startSearchInFolder.VirtualPath, virtualPath), realPath)); } else { realPath = CombineDirectory(rootResourceDirectoryPath, virtualPath); if (System.IO.File.Exists(realPath)) { return(new FileExisting(this, virtualPath, realPath)); } else { throw new FileNotFoundException("File " + CombineDirectory(startSearchInFolder.VirtualPath, virtualPath) + " doesnt exits"); } } }