public static void Apply(this SingleFile step, TemporaryFile downloadedFile, TemporaryDirectory workingDir)
        {
            #region Sanity checks
            if (step == null)
            {
                throw new ArgumentNullException(nameof(step));
            }
            if (downloadedFile == null)
            {
                throw new ArgumentNullException(nameof(downloadedFile));
            }
            if (workingDir == null)
            {
                throw new ArgumentNullException(nameof(workingDir));
            }
            #endregion

            if (string.IsNullOrEmpty(step.Destination))
            {
                throw new IOException(Resources.FileMissingDest);
            }

            var    builder         = new DirectoryBuilder(workingDir);
            string destinationPath = builder.NewFilePath(
                FileUtils.UnifySlashes(step.Destination),
                FileUtils.FromUnixTime(0),
                step.Executable);
            FileUtils.Replace(downloadedFile, destinationPath);
            builder.CompletePending();
        }
Example #2
0
 /// <inheritdoc/>
 protected override void HandleSymlink(FileSystemInfo symlink, string target)
 {
     if (symlink == null)
     {
         throw new ArgumentNullException(nameof(symlink));
     }
     if (string.IsNullOrEmpty(target))
     {
         throw new ArgumentNullException(nameof(target));
     }
     if (symlink.Name == SourceFileName)
     {
         DirectoryBuilder.CreateSymlink(TargetFileName, target);
     }
 }
 public DirectoryBuilderTest()
 {
     _tempDir = new TemporaryDirectory("0install-unit-tests");
     _builder = new DirectoryBuilder(_tempDir);
 }
Example #4
0
 /// <inheritdoc/>
 protected override string NewFilePath(FileInfo originalFile, DateTime?lastWriteTime, bool executable)
 => DirectoryBuilder.NewFilePath(TargetFileName, lastWriteTime, executable);