Ejemplo n.º 1
0
        private void MergeDirectory()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.AddExtension = true;
            dlg.Title        = "Merge Folder";
            if (dlg.ShowDialog() == true)
            {
                var path = GetSelectedFolderPath();
                if (path != null && !_bundle.DirectoryExists(path))
                {
                    _bundle.CreateDirectory(path);
                }

                var bundleFiles = new List <string>(_bundle.GetFiles());

                var newBundle = new FileBundleEx(_bundle.FileName.Replace(".jbd", ".tmp.jbd"), 719); // TODO: numBuckets = prime_ceil(bundleFiles / 16)

                var folder = Path.GetDirectoryName(dlg.FileNames[0]);
                var files  = Directory.GetFiles(folder);

                Progress.Reset(files.Length + bundleFiles.Count);
                Progress.Label     = "Merging";
                Progress.IsEnabled = true;

                _backgroundWorkerService.RunAsync(() => Merge(newBundle, _bundle, bundleFiles, files));
            }
        }
Ejemplo n.º 2
0
        private void Merge(FileBundleEx destBundle, FileBundle srcBundle, List <string> bundleFiles, IEnumerable <string> files)
        {
            destBundle.BeginWrite();

            var paths = new List <string>();
            var path  = GetSelectedFolderPath();

            AddPath(destBundle, path);
            paths.Add(path);

            foreach (var fileName in files)
            {
                string file = Path.GetFileName(fileName);
                if (path != null)
                {
                    file = String.Format("{0}\\{1}", path, file);
                }

                for (int i = 0; i < bundleFiles.Count; i++)
                {
                    if (String.Compare(bundleFiles[i], file, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        bundleFiles.RemoveAt(i);
                        Progress.Current++;
                        break;
                    }
                }

                FileInfo info = new FileInfo(fileName);
                InjectFile(destBundle, file, fileName, info.LastWriteTimeUtc);

                Progress.Current++;
            }

            foreach (var file in bundleFiles)
            {
                int index = file.LastIndexOf('\\');
                if (index > 0)
                {
                    path = file.Substring(0, index);
                    if (!paths.Contains(path))
                    {
                        AddPath(destBundle, path);
                        paths.Add(path);
                    }
                }

                CopyFile(destBundle, srcBundle, file);
                Progress.Current++;
            }

            destBundle.EndWrite();

            _backgroundWorkerService.InvokeOnUiThread(() =>
            {
                Progress.IsEnabled = false;
            });
        }
Ejemplo n.º 3
0
        private void CreateBundle()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.AddExtension    = true;
            dlg.DefaultExt      = "jbd";
            dlg.Filter          = "Jamiras Bundle (*.jbd)|*.jbd";
            dlg.FilterIndex     = 1;
            dlg.Multiselect     = false;
            dlg.CheckFileExists = false;
            dlg.Title           = "Create File";
            if (dlg.ShowDialog() == true)
            {
                Bundle = new FileBundleEx(dlg.FileName);
                AddRecentFile(dlg.FileName);
            }
        }
Ejemplo n.º 4
0
 private void OpenBundle(string fileName)
 {
     Bundle = new FileBundleEx(fileName);
     AddRecentFile(fileName);
 }