Ejemplo n.º 1
0
        internal bool Reroot(string iDirectory, IImportContext Context, bool AddCustomDir)
        {
            if (!Directory.Exists(iDirectory))
            {
                Context.OnFactorisableError<OutputDirectoryNotFound>(this.ToString());
                return false;
            }

            bool del1 = false;
            bool del2 = false;
            DirectoryInfo di = null;
            DirectoryInfo di2 = null;

            string path = iDirectory;


            if (AddCustomDir)
            {
                string OutDirector = Path.Combine(iDirectory, Author.FormatFileName());

                di = new DirectoryInfo(OutDirector);
                if (!di.Exists)
                {
                    di.Create();
                    del1 = true;
                }

                string FinalDirectory = Path.Combine(OutDirector, Name.FormatFileName());

                di2 = new DirectoryInfo(FinalDirectory);
                if (!di2.Exists)
                {
                    di2.Create();
                    del2 = true;
                }
                path = FinalDirectory;
            }

            bool sm = false;

            var init = (from t in CrudeTracks where t.IsBroken == false select t.Path).ToList();
            var TobeMoved = CrudeTracks.ToList();

            foreach (Track tr in TobeMoved)
            {
                if (tr.ReRoot(path, Context))
                {
                    sm = true;
                }
                else
                {
                    Context.OnFactorisableError<UnableToCopyFile>(tr.ToString());
                }
            }

            if (sm)
            {
                Context.Folders.GetFileCleanerFromFiles(init, Context.Folders.IsFileRemovable, true).Remove();
            }
            else
            {
                if (del1)
                    di.Delete(true);
                else if (del2)
                    di2.Delete(true);
            }

            return sm;
        }
        internal void Import(IImportContext Context)
        {
            try
            {
                string Dest = FileHelper.CreateMusicalFolder(new DiscInfoCue(Name,Artist));

                if (!Context.XMLManager.RemoveFileOriginal)
                {
                    System.IO.File.Copy(Path, Dest);
                }
                else
                {
                    System.IO.File.Move(Path, Dest);
                }

                Path = Dest;
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem moving files {0}", e);
                Context.OnFactorisableError<UnableToCopyFile>(Path);
            }
        }