Example #1
0
 public void Save()
 {
     try
     {
         List <string> writeList = new List <string>();
         writeList.AddRange(modList.Select(mod => mod.FileName));
         for (int i = 0; i < writeList.Count; i++)
         {
             writeList[i] =
                 OSUtils.GetRelativePath(writeList[i], Path.GetFullPath(Inst.InstModsDir));
         }
         File.WriteAllLines(Inst.ModListFile, writeList);
     } catch (IOException e)
     {
         if (e.Message.ToLower().Contains("in use"))
         {
             Console.WriteLine("Failed to save mod list because " +
                               "something else was using the file.");
         }
         else
         {
             throw;
         }
     }
 }
Example #2
0
        void FileRenamed(object sender, RenamedEventArgs e)
        {
            string oldPath = OSUtils.GetRelativePath(e.OldFullPath,
                                                     Path.GetFullPath(Environment.CurrentDirectory));

            string path = OSUtils.GetRelativePath(e.FullPath, Path.GetFullPath(
                                                      Path.GetFullPath(Environment.CurrentDirectory)));

            int index = this[oldPath];

            this[index] = new Mod(path);
            Save();
        }
Example #3
0
        void FileChanged(object sender, FileSystemEventArgs e)
        {
            foreach (string ignore in ignoreList)
            {
                Console.WriteLine(Path.GetFullPath(e.FullPath));
                Console.WriteLine(Path.GetFullPath(ignore));

                if (Path.GetFullPath(ignore) ==
                    Path.GetFullPath(e.FullPath))
                {
                    return;
                }
            }

            string filePath =
                OSUtils.GetRelativePath(e.FullPath, Environment.CurrentDirectory);

            switch (e.ChangeType)
            {
            case WatcherChangeTypes.Created:
                RecursiveAdd(filePath);
                Save();
                break;

            case WatcherChangeTypes.Deleted:
                Remove(modList.Where(m => m.FileName == filePath));
                Save();
                break;

            case WatcherChangeTypes.Changed:
                Inst.NeedsRebuild = true;
                break;

            default:
                break;
            }
        }