Ejemplo n.º 1
0
        public void AttemptDeletions()
        {
            lock (PendingDelete) {
                int oldCount = PendingDelete.Count;
                for (int i = PendingDelete.Count - 1; i >= 0; i--)
                {
                    string path = System.IO.Path.Combine(Sys.Settings.LibraryLocation, PendingDelete[i]);
                    try {
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                        else if (System.IO.Directory.Exists(path))
                        {
                            System.IO.Directory.Delete(path, true);
                        }
                    } catch (System.IO.IOException) {
                        System.Diagnostics.Debug.Write(String.Format("File {0} could not be accessed - in use? Leaving in list.", path));
                        continue;
                    }
                    System.Diagnostics.Debug.Write(String.Format("File {0} successfully deleted.", path));
                    PendingDelete.RemoveAt(i);
                }

                if (oldCount != PendingDelete.Count)
                {
                    Sys.Save();
                }
            }
        }
Ejemplo n.º 2
0
        public void QueuePendingDelete(IEnumerable <string> files)
        {
            if (PendingDelete == null)
            {
                PendingDelete = new List <string>();
            }

            lock (_pendingLock)
                PendingDelete.AddRange(files);
        }
Ejemplo n.º 3
0
        public void AddInstall(InstalledItem ii)
        {
            var exist = GetItem(ii.ModID); //forces lookup creation

            if (exist != null)
            {
                Items.Remove(exist);
            }
            Items.Add(ii);
            _lookup[ii.ModID] = ii;
            PendingDelete.RemoveAll(s => s.Equals(ii.LatestInstalled.InstalledLocation, StringComparison.InvariantCultureIgnoreCase));
            Sys.SetStatus(ii.ModID, ModStatus.Installed);
            Sys.Save();
        }
Ejemplo n.º 4
0
        public void AttemptDeletions()
        {
            lock (_pendingLock)
            {
                int oldCount = PendingDelete.Count;
                for (int i = PendingDelete.Count - 1; i >= 0; i--)
                {
                    string path = Path.Combine(Sys.Settings.LibraryLocation, PendingDelete[i]);
                    try
                    {
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                        else if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }
                    }
                    catch (IOException ioex)
                    {
                        Sys.Message(new WMessage($"File {path} could not be accessed - in use? Leaving in list.", WMessageLogLevel.LogOnly, ioex));
                        continue;
                    }
                    catch (Exception ex)
                    {
                        Sys.Message(new WMessage($"Unknown exception deleting {path} - Leaving in list.", WMessageLogLevel.LogOnly, ex));
                        continue;
                    }

                    Sys.Message(new WMessage($"File {path} successfully deleted.", WMessageLogLevel.LogOnly));
                    PendingDelete.RemoveAt(i);
                }

                if (oldCount != PendingDelete.Count)
                {
                    Sys.SaveLibrary();
                }
            }
        }
Ejemplo n.º 5
0
 public void QueuePendingDelete(IEnumerable <string> files)
 {
     lock (PendingDelete)
         PendingDelete.AddRange(files);
 }