Exemplo n.º 1
0
        /// <summary>
        /// Decompress an encrypted FAES File.
        /// </summary>
        /// <param name="encryptedFile">Encrypted FAES File</param>
        /// <param name="overridePath">Override the read path</param>
        /// <returns>Path of the encrypted, Decompressed file</returns>
        public string DecompressFAESFile(FAES_File encryptedFile, string overridePath = "")
        {
            string fileCompressionMode = FileAES_Utilities.GetCompressionMode(encryptedFile.GetPath());

            Logging.Log(String.Format("Compression Mode: {0}", fileCompressionMode), Severity.DEBUG);

            switch (fileCompressionMode)
            {
            case "LZMA":
                LZMA lzma = new LZMA();
                return(lzma.DecompressFAESFile(encryptedFile, overridePath));

            case "TAR":
                TAR tar = new TAR();
                return(tar.DecompressFAESFile(encryptedFile, overridePath));

            case "ZIP":
                ZIP zip = new ZIP(_compressionLevel);
                return(zip.DecompressFAESFile(encryptedFile, overridePath));

            case "LEGACY":
            case "LEGACYZIP":
            case "LGYZIP":
                LegacyZIP legacyZip = new LegacyZIP();
                return(legacyZip.DecompressFAESFile(encryptedFile, overridePath));

            default:
                throw new NotSupportedException("FAES File was compressed using an unsupported file format.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compress an unencrypted FAES File.
        /// </summary>
        /// <param name="unencryptedFile">Unencrypted FAES File</param>
        /// <returns>Path of the unencrypted, compressed file</returns>
        public string CompressFAESFile(FAES_File unencryptedFile)
        {
            switch (_compressionMode)
            {
            case CompressionMode.LZMA:
                LZMA lzma = new LZMA();
                Logging.Log("Compression Mode: LZMA", Severity.DEBUG);
                return(lzma.CompressFAESFile(unencryptedFile));

            case CompressionMode.TAR:
                TAR tar = new TAR();
                Logging.Log("Compression Mode: TAR", Severity.DEBUG);
                return(tar.CompressFAESFile(unencryptedFile));

            case CompressionMode.LGYZIP:
                LegacyZIP legacyZIP = new LegacyZIP();
                Logging.Log("Compression Mode: LEGACYZIP", Severity.DEBUG);
                return(legacyZIP.CompressFAESFile(unencryptedFile));

            default:
            {
                ZIP zip;
                Logging.Log("Compression Mode: ZIP", Severity.DEBUG);

                if (_compressionLevelRaw < 0)
                {
                    Logging.Log(String.Format("Compression Level: {0}", _compressionLevel), Severity.DEBUG);
                    zip = new ZIP(_compressionLevel);
                }
                else
                {
                    Logging.Log(String.Format("Compression Level: {0}", _compressionLevelRaw), Severity.DEBUG);
                    zip = new ZIP(_compressionLevelRaw);
                }
                return(zip.CompressFAESFile(unencryptedFile));
            }
            }
        }
Exemplo n.º 3
0
    // Public Static Method to load an uncompressed TAR file
    public static TAR LoadTARFile(string filename)
    {
        TAR archive = new TAR(filename, false);

        return(archive);
    }
    public void OnEnable()
    {
        // Check that we have a valid TAR Archive filename
        if (string.IsNullOrEmpty(tarFileName) || !File.Exists(tarFileName))
        {
            return;
        }

        // Check if the extension is .tgz or .gz
        if (Path.GetExtension(tarFileName).Equals(".tgz", StringComparison.InvariantCultureIgnoreCase) ||
            Path.GetExtension(tarFileName).Equals(".gz", StringComparison.InvariantCultureIgnoreCase))
        {
            // If so, open it as a compressed TGZ file
            tarArchive = TAR.LoadTGZFile(tarFileName);
        }
        else
        {
            // Otherwise open it as an uncompressed TAR file
            tarArchive = TAR.LoadTARFile(tarFileName);
        }

        //Create a list to store entries
        tarEntries = new List <TAR.TARMetaData>();

        //Loop through all the entries
        foreach (TAR.TARMetaData entry in tarArchive.Entries)
        {
            // And if it's a normal file
            if (entry.GetTypeFlags() == TAR.TARMetaData.TypeFlags.NormalFile)
            {
                //Add it to the list of entries we're tracking
                tarEntries.Add(entry);
            }
        }

        // The "makeItem" function will be called as needed
        // when the ListView needs more items to render
        Func <VisualElement> makeItem = () => {
            // We'll use a reverse row flex direction, as we want to
            // Keep the buttons a standard size, but have the label flexgrow
            VisualElement ve = new VisualElement();
            ve.style.flexDirection = FlexDirection.RowReverse;
            ve.style.flexShrink    = 0;

            // Create the Label
            Label label = new Label("FILENAME");
            label.style.flexGrow   = 1f;
            label.style.flexShrink = 0f;
            label.style.flexBasis  = 0f;

            // Create the Extract button
            Button extract_Button = new Button(() => { Extract(label.text); });
            extract_Button.text        = "EXTRACT";
            extract_Button.style.width = 100;

            // Create the Remove Button
            Button remove_Button = new Button(() => { Remove(label.text); });
            remove_Button.text        = "REMOVE";
            remove_Button.style.width = 100;

            // Add the items in reverse order
            ve.Add(remove_Button);
            ve.Add(extract_Button);
            ve.Add(label);
            return(ve);
        };

        // As the user scrolls through the list, the ListView object
        // will recycle elements created by the "makeItem"
        // and invoke the "bindItem" callback to associate
        // the element with the matching data item (specified as an index in the list)

        // In this case, we get the last item, as the label is the last thing we add
        Action <VisualElement, int> bindItem = (e, i) => { (new List <VisualElement>(e.Children())[2] as Label).text = tarEntries[i].fileName; };

        // Provide the list view with an explict height for every row
        // so it can calculate how many items to actually display
        const int itemHeight = 15;

        // Create the list view
        var listView = new ListView(tarEntries, itemHeight, makeItem, bindItem);

        listView.selectionType  = SelectionType.None;
        listView.style.flexGrow = 0.95f;

        // Remove any remaining items in the window
        rootVisualElement.Clear();

        // Create our button to add Files
        Button add_Button = new Button(() => { AddFile(); });

        add_Button.text = "ADD FILE";

        // Add our title, list view, and add button
        rootVisualElement.Add(new Label(tarFileName + " Contents"));
        rootVisualElement.Add(listView);
        rootVisualElement.Add(add_Button);
    }
Exemplo n.º 5
0
    // Public Static Method to load a compressed TGZ file
    public static TAR LoadTGZFile(string filename)
    {
        TAR archive = new TAR(filename, true);

        return(archive);
    }