Esempio n. 1
0
    public override void Verify(string parentPath)
    {
        string path = Path.Combine(parentPath, Name);

        (File.Exists(path) || Directory.Exists(path)).Should().BeTrue(because: $"Symlink '{path}' should exist.");

        ImplFileUtils.IsSymlink(path, out string?target).Should().BeTrue(because: $"'{path}' should be a symlink.");
        target.Should().Be(Target, because: $"Symlink '{path}' should point to correct target.");
    }
Esempio n. 2
0
    /// <inheritdoc/>
    protected override void HandleFile(FileInfo file, FileInfo?hardlinkTarget = null)
    {
        if (Manifest.RejectPath(file.RelativeTo(Source)))
        {
            return;
        }

        var element = GetManifestElement(file);

        if (ImplFileUtils.IsSymlink(file.FullName, out string?symlinkTarget, element))
        {
            _builder.AddSymlink(file.RelativeTo(Source), symlinkTarget);
            return;
        }

        if (!FileUtils.IsRegularFile(file.FullName))
        {
            throw new NotSupportedException(string.Format(Resources.IllegalFileType, file.FullName));
        }

        bool executable = ImplFileUtils.IsExecutable(file.FullName, element);

        try
        {
            if (hardlinkTarget != null)
            {
                _builder.AddHardlink(file.RelativeTo(Source), hardlinkTarget.RelativeTo(Source), executable);
                return;
            }
        }
        catch (NotSupportedException)
        {}

        using var stream = file.OpenRead();
        _builder.AddFile(file.RelativeTo(Source), stream, file.LastWriteTimeUtc, executable);
    }