Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 8b1549a153a62e9878327d05aa3b6622b416ec10 authored by Matt Caswell on 02 November 2017, 14:33:44 UTC, committed by Matt Caswell on 02 November 2017, 14:33:44 UTC
Prepare for 1.0.2m release
Reviewed-by: Andy Polyakov <appro@openssl.org>
1 parent c7a906b
  • Files
  • Changes
  • 7a99d2e
  • /
  • util
  • /
  • copy-if-different.pl
Raw File
Cook and download a directory from the Software Heritage Vault

You have requested the cooking of the directory with identifier None into a standard tar.gz archive.

Are you sure you want to continue ?

Download a directory from the Software Heritage Vault

You have requested the download of the directory with identifier None as a standard tar.gz archive.

Are you sure you want to continue ?

Cook and download a revision from the Software Heritage Vault

You have requested the cooking of the history heading to revision with identifier swh:1:rev:8b1549a153a62e9878327d05aa3b6622b416ec10 into a bare git archive.

Are you sure you want to continue ?

Download a revision from the Software Heritage Vault

You have requested the download of the history heading to revision with identifier swh:1:rev:8b1549a153a62e9878327d05aa3b6622b416ec10 as a bare git archive.

Are you sure you want to continue ?

Invalid Email !

The provided email is not well-formed.

Download link has expired

The requested archive is no longer available for download from the Software Heritage Vault.

Do you want to cook it again ?

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • content
revision badge
swh:1:rev:8b1549a153a62e9878327d05aa3b6622b416ec10
content badge Iframe embedding
swh:1:cnt:e1245f54aff120d68956208eb9d772434060a87b
copy-if-different.pl
#!/usr/local/bin/perl

use strict;

use Fcntl;

# copy-if-different.pl

# Copy to the destination if the source is not the same as it.

my @filelist;

foreach my $arg (@ARGV) {
	$arg =~ s|\\|/|g;	# compensate for bug/feature in cygwin glob...
	foreach (glob qq("$arg"))
		{
		push @filelist, $_;
		}
}

my $fnum = @filelist;

if ($fnum <= 1)
	{
	die "Need at least two filenames";
	}

my $dest = pop @filelist;

if ($fnum > 2 && ! -d $dest)
	{
	die "Destination must be a directory";
	}

foreach (@filelist)
	{
        my $dfile;
	if (-d $dest)
		{
		$dfile = $_;
		$dfile =~ s|^.*[/\\]([^/\\]*)$|$1|;
		$dfile = "$dest/$dfile";
		}
	else
		{
		$dfile = $dest;
		}

	my $buf;
	if (-f $dfile)
		{
		sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
		sysopen(OUT, $dfile, O_RDONLY|O_BINARY)
		  || die "Can't Open $dfile";
		while (sysread IN, $buf, 10240)
			{
			my $b2;
			goto copy if !sysread(OUT, $b2, 10240) || $buf ne $b2;
			}
		goto copy if sysread(OUT, $buf, 1);
		close(IN);
		close(OUT);
		print "NOT copying: $_ to $dfile\n";
		next;
		}
      copy:
	sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
	sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
					|| die "Can't Open $dfile";
	while (sysread IN, $buf, 10240)
		{
		syswrite(OUT, $buf, length($buf));
		}
	close(IN);
	close(OUT);
	print "Copying: $_ to $dfile\n";
	}

The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top