public static ConfigNode ToConfigNode(this HarddiskFile file, string nodeName)
        {
            var node = new ConfigNode(nodeName);

            node.AddValue(FilenameValueString, file.Name);

            FileContent content = file.ReadAll();

            if (content.Category == FileCategory.KSM)
            {
                node.AddValue("line", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else
            {
                if (SafeHouse.Config.UseCompressedPersistence)
                {
                    node.AddValue("line", EncodeBase64(content.String));
                }
                else
                {
                    node.AddValue("line", PersistenceUtilities.EncodeLine(content.String));
                }
            }
            return(node);
        }
        public static ConfigNode ToConfigNode(this HarddiskDirectory directory, string nodeName)
        {
            ConfigNode node = new ConfigNode(nodeName);

            node.AddValue(DirnameValueString, directory.Name);

            foreach (VolumeItem item in directory)
            {
                if (item is HarddiskDirectory)
                {
                    HarddiskDirectory dir = item as HarddiskDirectory;
                    node.AddNode(dir.ToConfigNode("directory"));
                }

                if (item is HarddiskFile)
                {
                    HarddiskFile file = item as HarddiskFile;
                    node.AddNode(file.ToConfigNode("file"));
                }
            }

            return(node);
        }