/// <summary>Provides package descriptor</summary> /// <param name="name">Mnemonic name of the package (i.e. application name)</param> /// <param name="source">Source directory where to take files from</param> /// <param name="relPath">Relative path which is appended to the root path where files will be placed</param> public PackageInfo(string name, FileSystemDirectory source, string relPath) { Name = name ?? CoreConsts.UNKNOWN; Source = source; RelativePath = relPath; ConfigSectionNode manifest = null; var mFile = source.GetFile(ManifestUtils.MANIFEST_FILE_NAME); if (mFile!=null) try { manifest = LaconicConfiguration.CreateFromString(mFile.ReadAllText()).Root; } catch(Exception error) { throw new NFXIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_MANIFEST_READ_ERROR.Args(Name, error.ToMessageWithType()), error); } if (manifest==null) throw new NFXIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_WITHOUT_MANIFEST_ERROR.Args(Name, ManifestUtils.MANIFEST_FILE_NAME)); manifest.AttrByName(ManifestUtils.CONFIG_NAME_ATTR, true).Value = name; manifest.AttrByName(ManifestUtils.CONFIG_LOCAL_PATH_ATTR, true).Value = relPath; manifest.ResetModified(); Manifest = manifest; }
/// <summary>Provides package descriptor</summary> /// <param name="name">Mnemonic name of the package (i.e. application name)</param> /// <param name="source">Source directory where to take files from</param> /// <param name="relPath">Relative path which is appended to the root path where files will be placed</param> public PackageInfo(string name, FileSystemDirectory source, string relPath) { Name = name ?? CoreConsts.UNKNOWN; Source = source; RelativePath = relPath; ConfigSectionNode manifest = null; var mFile = source.GetFile(ManifestUtils.MANIFEST_FILE_NAME); if (mFile != null) { try { manifest = LaconicConfiguration.CreateFromString(mFile.ReadAllText()).Root; } catch (Exception error) { throw new AzosIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_MANIFEST_READ_ERROR.Args(Name, error.ToMessageWithType()), error); } } if (manifest == null) { throw new AzosIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_WITHOUT_MANIFEST_ERROR.Args(Name, ManifestUtils.MANIFEST_FILE_NAME)); } manifest.AttrByName(ManifestUtils.CONFIG_NAME_ATTR, true).Value = name; manifest.AttrByName(ManifestUtils.CONFIG_LOCAL_PATH_ATTR, true).Value = relPath; manifest.ResetModified(); Manifest = manifest; }
public void Variable_defined_by_nested_import_is_replaced_in_CSS_output() { using (var path = new TempDirectory()) { File.WriteAllText(Path.Combine(path, "main.less"), "@import 'first.less';\np { color: @c }"); File.WriteAllText(Path.Combine(path, "first.less"), "@import 'second.less';"); File.WriteAllText(Path.Combine(path, "second.less"), "@c: red;"); var directory = new FileSystemDirectory(path); var file = directory.GetFile("main.less"); var compiler = new LessCompiler(); var css = compiler.Compile(file.OpenRead().ReadToEnd(), file); css.ShouldContain("color: red;"); } }
private static void buildDirLevel(ConfigSectionNode pNode, FileSystemDirectory directory) { const int BUFF_SIZE = 64 * 1024; foreach (var sdn in directory.SubDirectoryNames) { using (var sdir = directory.GetSubDirectory(sdn)) { var dnode = pNode.AddChildNode(CONFIG_DIR_SECTION); dnode.AddAttributeNode(CONFIG_NAME_ATTR, sdir.Name); buildDirLevel(dnode, sdir); } } foreach (var fn in directory.FileNames.Where(fn => !MANIFEST_FILE_NAME.EqualsIgnoreCase(fn))) { using (var file = directory.GetFile(fn)) { var fnode = pNode.AddChildNode(CONFIG_FILE_SECTION); fnode.AddAttributeNode(CONFIG_NAME_ATTR, file.Name); long size = 0; var csum = new Adler32(); var buff = new byte[BUFF_SIZE]; using (var fs = file.FileStream) while (true) { var read = fs.Read(buff, 0, BUFF_SIZE); if (read <= 0) { break; } size += read; csum.Add(buff, 0, read); } fnode.AddAttributeNode(CONFIG_SIZE_ATTR, size); fnode.AddAttributeNode(CONFIG_CSUM_ATTR, csum.Value); } } }
public void ItCreatesManifestXmlFile() { directory.GetFile("manifest.xml").Exists.ShouldBeTrue(); }
private static void buildDirLevel(ConfigSectionNode pNode, FileSystemDirectory directory) { const int BUFF_SIZE = 64 * 1024; foreach(var sdn in directory.SubDirectoryNames) using(var sdir = directory.GetSubDirectory(sdn)) { var dnode = pNode.AddChildNode(CONFIG_DIR_SECTION); dnode.AddAttributeNode(CONFIG_NAME_ATTR, sdir.Name); buildDirLevel(dnode, sdir); } foreach(var fn in directory.FileNames.Where(fn => !string.Equals(fn, MANIFEST_FILE_NAME, StringComparison.InvariantCultureIgnoreCase))) using(var file = directory.GetFile(fn)) { var fnode = pNode.AddChildNode(CONFIG_FILE_SECTION); fnode.AddAttributeNode(CONFIG_NAME_ATTR, file.Name); long size = 0; var csum = new Adler32(); var buff = new byte[BUFF_SIZE]; using(var fs = file.FileStream) while(true) { var read = fs.Read(buff, 0, BUFF_SIZE); if (read<=0) break; size += read; csum.Add(buff, 0, read); } fnode.AddAttributeNode(CONFIG_SIZE_ATTR, size); fnode.AddAttributeNode(CONFIG_CSUM_ATTR, csum.Value); } }