Esempio n. 1
0
 protected override void AddElements(IForwardOnlyBuilder builder)
 {
     builder.AddFile("normal", TestFile.DefaultContents.ToStream(), TestFile.DefaultLastWrite);
     builder.AddFile("executable", TestFile.DefaultContents.ToStream(), TestFile.DefaultLastWrite, executable: true);
     builder.AddSymlink("symlink", target: "normal");
     builder.AddHardlink("hardlink", target: "normal");
     builder.AddDirectory("dir");
     builder.AddFile(Path.Combine("dir", "sub"), TestFile.DefaultContents.ToStream(), TestFile.DefaultLastWrite);
 }
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);
    }