Esempio n. 1
0
        public static void FtpUploadDirectoryRecursively(string directory, string hostRoot)
        {
            Logger.Info($"Uploading directory '{directory}' to '{hostRoot}'...");

            var files = PathConstruction.GlobFiles(directory, "**/*").ToList();

            for (var index = 0; index < files.Count; index++)
            {
                var file         = files[index];
                var relativePath = PathConstruction.GetRelativePath(directory, file);
                var hostPath     = $"{hostRoot}/{relativePath}";

                FtpUploadFileInternal(file, hostPath, $"[{index + 1}/{files.Count}] ");
            }
        }
Esempio n. 2
0
        public static void DeleteDirectory(string directory)
        {
            if (!Directory.Exists(directory))
            {
                return;
            }

            if (PathConstruction.IsDescendantPath(EnvironmentInfo.BuildProjectDirectory, directory))
            {
                Logger.Warn($"Skipping directory '{directory}' because it is contained in the build project directory...");
                return;
            }

            Logger.Info($"Deleting directory '{directory}'...");
            DeleteDirectoryInternal(directory);
        }
Esempio n. 3
0
        private static void CopyRecursivelyInternal(string source, string target, FileExistsPolicy policy)
        {
            string GetDestinationPath(string path)
            => Path.Combine(target, PathConstruction.GetRelativePath(source, path));

            Directory.CreateDirectory(target);
            Directory.GetDirectories(source).ForEach(x => CopyRecursivelyInternal(x, GetDestinationPath(x), policy));

            foreach (var sourceFile in Directory.GetFiles(source))
            {
                var targetFile = GetDestinationPath(sourceFile);
                if (!ShouldCopyFile(sourceFile, targetFile, policy))
                {
                    continue;
                }

                //EnsureFileAttributes(sourceFile);
                File.Copy(sourceFile, targetFile, overwrite: true);
            }
        }