Esempio n. 1
0
        static void ArchiveExistingExport(string targetPath)
        {
            Console.WriteLine("Archiving existing export data...");
            try {
                if (!Directory.Exists(targetPath))
                {
                    throw new Exception("Export folder does not exist.");
                }

                var files = Directory.GetFiles(targetPath, "*.bin");

                if (files.Length > 0)
                {
                    string fn = System.IO.Path.Combine(targetPath, string.Format("OneTab-Archive-{0:yyyy-MM-dd_hh-mm}.zip", DateTime.Now));

                    ZipFileCreator.CreateZipFile(fn, files);

                    foreach (var item in files)
                    {
                        if (File.Exists(item))
                        {
                            File.Delete(item);
                        }
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine("Error archiving existing export data: " + ex.Message);
            }
        }
Esempio n. 2
0
        static void ExportDb(string path, string key, string[] keys, string targetPath, bool saveToArchive)
        {
            try
            {
                if (DbOpen(path))
                {
                    string[] files = (string[])keys.Clone();

                    // Binary output of data. These can be used for importing.
                    bool first = true;
                    for (int i = 0; i < keys.Length; i++)
                    {
                        _ExportKey(targetPath, key, keys[i], first);
                        files[i] = keys[i] + ".bin";
                        first    = false;
                    }

                    Array.Resize(ref files, files.Length + 1);
                    files[files.Length - 1] = keys[0] + ".json";

                    // DbClose();
                    // If saving to archive, MOVE all files to ZIP file.
                    if (saveToArchive)
                    {
                        string fn = string.Format("OneTab-{0:yyyy-MM-dd_hh-mm}.zip", DateTime.Now);

                        ZipFileCreator.CreateZipFile(fn, files);

                        foreach (var item in files)
                        {
                            if (File.Exists(item))
                            {
                                File.Delete(item);
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("ERROR: Could not open the filedb database. Please make sure you have closed all browser windows, then try again.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
            }
            finally
            {
                DbClose();
                //if (ums != null) ums.Dispose();
                // ums = null;
            }
        }
Esempio n. 3
0
        //string path = "d:/_MyProjects/OneTabSorter/ExportOneTab/leveldb";
        //string path = @"c:\Users\Andrey\AppData\Local\Vivaldi\User Data\Default\Local Storage\leveldb\";

        static void Main(string[] args)
        {
            string path = args[0];

            if (path == "")
            {
                Console.WriteLine("Please set path to chrome or vivaldi leveldb folder");
            }


            // "--" is replaced by zero bytes in c++ dll
            string key = "_chrome-extension://chphlpgkkbolifaimnlloiipkdnihall--";


            if (DbOpen(path))
            {
                //var keys = new string[] {
                //    "state", "topSites", "settings", "lastSeenVersion",
                //    "installDate", "idCounter", "extensionKey"
                //};
                var keys = new string[] { "state" };

                string[] files = (string[])keys.Clone();

                bool first = true;
                for (int i = 0; i < keys.Length; i++)
                {
                    DoIt(key, keys[i], first);
                    files[i] = keys[i] + ".bin";
                    first    = false;
                }

                Array.Resize(ref files, files.Length + 1);
                files[files.Length - 1] = keys[0] + ".json";

                DbClose();

                string fn = string.Format("OneTab-{0:yyyy-MM-dd_hh-mm}.zip", DateTime.Now);

                ZipFileCreator.CreateZipFile(fn, files);

                foreach (var item in files)
                {
                    if (File.Exists(item))
                    {
                        File.Delete(item);
                    }
                }
            }
            //Console.ReadKey();
        }
 private void OKButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     DialogResult = true;
     ZipFileCreator.CreateZipFile(SelectedFiles, ResponseText);
 }