Ejemplo n.º 1
0
        private void CopyIfDifferent(string sourcePath, IEnumerable <string> destinationDirs)
        {
            Debug.Assert(fileWrapper.Exists(sourcePath),
                         string.Format(CultureInfo.InvariantCulture, "Could not find the loader .targets file at {0}", sourcePath));

            var sourceContent = fileWrapper.ReadAllText(sourcePath);
            var fileName      = Path.GetFileName(sourcePath);

            foreach (var destinationDir in destinationDirs)
            {
                var destinationPath = Path.Combine(destinationDir, fileName);

                if (!fileWrapper.Exists(destinationPath))
                {
                    directoryWrapper.CreateDirectory(destinationDir); // creates all the directories in the path if needed
                    fileWrapper.Copy(sourcePath, destinationPath, overwrite: false);
                    logger.LogDebug(Resources.MSG_InstallTargets_Copy, fileName, destinationDir);
                }
                else
                {
                    var destinationContent = fileWrapper.ReadAllText(destinationPath);

                    if (!string.Equals(sourceContent, destinationContent, StringComparison.Ordinal))
                    {
                        fileWrapper.Copy(sourcePath, destinationPath, overwrite: true);
                        logger.LogDebug(Resources.MSG_InstallTargets_Overwrite, fileName, destinationDir);
                    }
                    else
                    {
                        logger.LogDebug(Resources.MSG_InstallTargets_UpToDate, fileName, destinationDir);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 internal void ExistsAndCopy(string file, string moveTo, string folder1)
 {
     // Checks that the file does not already exists
     // Passes directory location then concatenates the file name onto it
     // Also passes target directory and concatenates file name
     if (!fileWrapper.Exists($"{moveTo}\\{file}"))
     {
         fileWrapper.Copy($"{folder1}\\{file}", $"{moveTo}\\{file}");
     }
 }
 private void BackupConfig()
 {
     _fileWrapper.Copy(_configFile, $"{_configFile}.orig");
 }