コード例 #1
0
ファイル: TestDriver.cs プロジェクト: 411blue/echo-backup
        public static void testUnTarGZip()
        {
            Logger.init(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2\\uncompress.log");
            Guid        myGuid      = Guid.NewGuid();
            string      archivePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2\\01010101-0101-0101-0101-010101010101_123_0.tgz";
            string      outputDir   = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2";
            RestoreTask rt          = new RestoreTask(archivePath, outputDir);

            rt.Add("cs 410 2012-12-09\\echo backup logo v1.png");
            StorageThread st = new StorageThread("", myGuid);

            st.EnqueueStorageTask(rt);
            Print("added task to storagethread");
            int x = 0;

            while (st.IsWorking())
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting for storagethread to finish working " + x);
            }
            Print("storagethread done");
            st.RequestStop();
            Print("requested stop of storagethread");
            while (st.IsAlive())
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting for storagethread to stop " + x);
            }
            Print("storagethread stopped");
            Console.WriteLine("press a key to continue");
            Console.ReadKey();
        }
コード例 #2
0
ファイル: TestDriver.cs プロジェクト: 411blue/echo-backup
        /// <summary>
        /// tests the basic Tar and GZip functionality.
        /// </summary>
        static void testTarGZip()
        {
            Console.WriteLine("starting testTarBzip2");
            byte[]        b         = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
            Guid          guid      = new Guid(b);
            string        tempPath  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch";
            string        tempPath2 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2";
            StorageThread st        = new StorageThread(tempPath, guid);
            BackupTask    task      = new BackupTask(tempPath, tempPath2, 123, 0);

            st.EnqueueStorageTask(task);
            Console.WriteLine("queued task");
            int x = 0;

            while (st.IsWorking())
            {
                x++;
                Console.WriteLine("waiting for thread to finish." + x);
                Thread.Sleep(1000);
            }
            Console.WriteLine("thread finished.");
            st.RequestStop();
            Console.WriteLine("requested thread terminate.");
            while (st.IsAlive())
            {
                x++;
                Console.WriteLine("waiting for thread to die. " + x);
                Thread.Sleep(1000);
            }
            Console.WriteLine("thread is dead.");
            Console.WriteLine("number of chunks: " + st.NumChunks());
            while (st.NumChunks() > 0)
            {
                Chunk c = st.DequeueChunk();
                Console.WriteLine(c);
            }

            Console.WriteLine("press a key to continue");
            Console.ReadKey();
        }