Esempio n. 1
0
        public static void BackUpFiles(this CuDir cuDir, string pattern)
        {
            var list = cuDir.Handler.GetCurrentBakDirectories().Select(x => x.LastPartAsUpper).ToList();
            var newBackUpFolderName = "";

            foreach (var i in Enumerable.Range(1, 100))
            {
                if (!list.Contains("BAK" + i))
                {
                    newBackUpFolderName = "BAK" + i;
                    break;
                }
            }
            if (newBackUpFolderName == "")
            {
                throw new Exception("Backup failed, so delete some backup folders --max backup folders limit reached");
            }

            CuDir backUpDir = cuDir.Container.ResolveICuDir(cuDir.Path) + newBackUpFolderName;

            backUpDir.Create();
            foreach (CuFile file in cuDir.GetFiles(pattern))
            {
                var newFiel = backUpDir - file.Name;
                Debug.WriteLine($"Move: {file} > {newFiel}");
                cuDir.Handler.Move(file, newFiel);
            }
        }
Esempio n. 2
0
 public static IEnumerable <ICuFile> GetFiles(this CuDir cuDir, string pattern)
 {
     foreach (var cuFile in cuDir.Handler.GetFiles(pattern))
     {
         yield return(cuFile);
     }
 }
Esempio n. 3
0
 public static void Create(this CuDir cuDir)
 {
     if (cuDir.Handler.HasDir())
     {
         throw new Exception("CuDir already exists " + cuDir.Path);
     }
     cuDir.Handler.Create();
 }
Esempio n. 4
0
 public static void BackUpSqlFiles(this CuDir cuDir)
 {
     BackUpFiles(cuDir, "*.sql");
 }
Esempio n. 5
0
 public static void DeleteFiles(this CuDir cuDir, string pattern)
 {
     cuDir.Handler.DeleteFiles(pattern);
 }