Exemplo n.º 1
0
        /*
         * Procedure 1- Recover single jpeg encoded data.
         *
         */
        public Tuple <String, String> procedure_1(String rawPath)
        {
            String outFile = "" + rawPath + ".jpg";

            Console.WriteLine("Running Procedure 1");
            if (!File.Exists(rawPath))
            {
                String msg = "Error - File does not exists.";
                return(Tuple.Create(outFile, msg));
            }
            Procedures main = new Procedures();

            Huffman.switchHuffman(1);
            Stopwatch watch = Stopwatch.StartNew();
            //String rawPath = @"C:\Users\Ahmad\Desktop\QCRIInternship\Code\jpeg-carver-csharp-master\Dataset\Original\deagon_test_4kib";

            //Check if file is jpeg or not
            FileStream tempFileStream = new FileStream(rawPath, FileMode.Open);
            //Reading stream changes position, retain original
            long cpoint = tempFileStream.Position;
            bool isJpeg = preCheck.isJpeg(tempFileStream);

            tempFileStream.Position = cpoint;
            Console.WriteLine("Is Jpeg File?: " + isJpeg);

            //Check if jpeg partial headers exist
            utils.recoverHuffmanHdr(tempFileStream);

            tempFileStream.Close();


            Program p = new Program(rawPath);

            utils.recoverSegment(rawPath, p);

            //Console.WriteLine(" Hell Yeah!!");

            watch.Stop();
            Console.WriteLine(watch.Elapsed);
            //Console.ReadLine();
            return(Tuple.Create(outFile, "Success"));
        }