Debian Codegraph @

bin/build/links2files

raw
1 #!/usr/bin/perl
2
3 ############################################################################
4 # This file is part of FreeFEM. #
5 # #
6 # FreeFEM is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU Lesser General Public License as #
8 # published by the Free Software Foundation, either version 3 of #
9 # the License, or (at your option) any later version. #
10 # #
11 # FreeFEM is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU Lesser General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU Lesser General Public License #
17 # along with FreeFEM. If not, see <http://www.gnu.org/licenses/>. #
18 ############################################################################
19 # SUMMARY : ...
20 # LICENSE : LGPLv3
21 # ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE
22 # AUTHORS : Antoine Le Hyaric
23 # E-MAIL : ...
24
25 use strict;
26
27 # if a file is a soft link, just convert it into a real file. I know this is dangerous if the file the link points to
28 # changes, but I don't have many choices to make the MinGW compilers work (they do not understand Cygwin softlinks).
29
30 traverse(<*>);
31
32 sub traverse{
33 foreach my $arg(@_){
34
35 # 4/12/10: under cygwin, "find" seems to have random problems (the file system lags behind when doing many file
36 # moves in quick succession?), so just replace it with a local recursive subroutine.
37
38 if(-d $arg){
39 print "links2files: traversing $arg...\n";
40 traverse(<$arg/*>);
41 next;
42 }
43
44 # do not use readlink -f because it does not exist on Mac. Result is in $org
45 my $org;
46 my $nextorg=$arg;
47 do{
48 $org=$nextorg;
49 $nextorg=`readlink $org`;
50 }while($nextorg ne '');
51
52 if(-l $arg){
53 chomp $org;
54 if(-e $org){
55 print "links2files: $arg -> $org\n";
56 unlink $arg;
57 system "cp $org $arg";
58
59 # sometimes on Cygwin the resulting file is of size zero and not readable by anyone? And then if we try again it
60 # works fine!
61 die "$arg is of size 0" unless -s $arg;
62 }
63 }
64 }
65 }
66
67 # Local Variables:
68 # mode:cperl
69 # ispell-local-dictionary:"british"
70 # coding:utf-8
71 # End: