599
|
1 |
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
# copy A.X.aaa to B.X.bbb for all X (32 chars) when given A.aaa B.bbb
|
|
15 |
#
|
|
16 |
#
|
|
17 |
|
|
18 |
|
|
19 |
my $source = shift;
|
|
20 |
my $target = shift;
|
|
21 |
|
|
22 |
my $errs = 0;
|
|
23 |
|
|
24 |
# copy invariant
|
|
25 |
use File::Copy;
|
|
26 |
if (-f $source)
|
|
27 |
{
|
|
28 |
if (copy($source, $target))
|
|
29 |
{
|
|
30 |
print "copy $source $target\n";
|
|
31 |
}
|
|
32 |
else
|
|
33 |
{
|
|
34 |
print "ERROR: failed copy $source $target\n";
|
|
35 |
$errs++;
|
|
36 |
}
|
|
37 |
}
|
|
38 |
|
|
39 |
# now think about variants
|
|
40 |
|
|
41 |
use File::Basename;
|
|
42 |
my $srcDir = dirname($source);
|
|
43 |
my $srcRoot = basename($source);
|
|
44 |
my $srcExt = "";
|
|
45 |
|
|
46 |
if ($srcRoot =~ /^(.+)\.([^\.]+)$/)
|
|
47 |
{
|
|
48 |
$srcRoot = $1;
|
|
49 |
$srcExt = $2;
|
|
50 |
}
|
|
51 |
|
|
52 |
my $tgtRoot = $target;
|
|
53 |
my $tgtExt = "";
|
|
54 |
|
|
55 |
if ($tgtRoot =~ /^(.+)\.([^\.]+)$/)
|
|
56 |
{
|
|
57 |
$tgtRoot = $1;
|
|
58 |
$tgtExt = $2;
|
|
59 |
}
|
|
60 |
|
|
61 |
opendir(DIR, $srcDir) or die("ERROR: cannot read directory $srcDir\n");
|
|
62 |
|
|
63 |
# copy all variants
|
|
64 |
while (my $file = readdir(DIR))
|
|
65 |
{
|
|
66 |
if ($file =~ /^$srcRoot\.(\w{32})\.$srcExt$/i)
|
|
67 |
{
|
|
68 |
my $from = "$srcDir/$file";
|
|
69 |
my $into = "$tgtRoot.$1.$tgtExt";
|
|
70 |
|
|
71 |
if (copy($from, $into))
|
|
72 |
{
|
|
73 |
print "copy $from $into\n";
|
|
74 |
}
|
|
75 |
else
|
|
76 |
{
|
|
77 |
print "ERROR: failed copy $from $into\n";
|
|
78 |
$errs++;
|
|
79 |
}
|
|
80 |
}
|
|
81 |
}
|
|
82 |
|
|
83 |
exit 1 if (!closedir(DIR) || $errs > 0);
|
|
84 |
exit 0;
|
|
85 |
|