|
1 #!/usr/bin/perl |
|
2 # Copyright (c) 2010 Symbian Foundation Ltd |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of the License "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 # Mike Kinghan, mikek@symbian.org for Symbian Foundation Ltd - initial contribution. |
|
10 |
|
11 # Script delete backup files from the package directory. |
|
12 |
|
13 use strict; |
|
14 use usage; |
|
15 use File::Spec; |
|
16 use set_epocroot; |
|
17 |
|
18 sub delete_backups($); |
|
19 |
|
20 usage(\@ARGV,"This script deletes all files in the package directory " . |
|
21 "with names ending in '~'\n"); |
|
22 set_epocroot(); |
|
23 my $epocroot = $ENV{'EPOCROOT'}; |
|
24 my $build_pkg_dir = File::Spec->catfile("$epocroot","build"); |
|
25 my $deletes = 0; |
|
26 delete_backups($build_pkg_dir); |
|
27 print ">>> $deletes files deleted\n"; |
|
28 exit 0; |
|
29 |
|
30 sub delete_backups($) |
|
31 { |
|
32 my($path) = @_; |
|
33 print ">>> Weeding dir \"$path\"\n"; |
|
34 $path = File::Spec->catfile("$path",'*'); |
|
35 my @entries = glob($path); |
|
36 for my $entry (@entries) { |
|
37 if( -d $entry) { |
|
38 delete_backups($entry); |
|
39 } else { |
|
40 my @backups = grep(/~$/,@entries); |
|
41 foreach (@backups) { |
|
42 unlink $_; |
|
43 # Querying the result of unlink() for success is unreliable |
|
44 # on some tested systems. |
|
45 die "Failed to delete \"$_\"", if ( -f $_); |
|
46 ++$deletes; |
|
47 } |
|
48 } |
|
49 } |
|
50 } |
|
51 |