File: threadsafe.pl

package info (click to toggle)
fuse-convmvfs 0.2.4-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 464 kB
  • ctags: 63
  • sloc: sh: 787; cpp: 580; makefile: 66; perl: 36
file content (44 lines) | stat: -rw-r--r-- 827 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use strict;
use warnings;
use FindBin qw($Bin);
use Text::Iconv;
use File::Find;

sub runrun{
    print '+ ', join(' ', @_), "\n";
    system(@_) and die "Command failed\n";
}

chdir $Bin;
runrun 'tar', 'xf', 'music.tar';
mkdir 'music.gb18030';

my $conv = Text::Iconv->new('utf8', 'gb18030');
my %imap;
find(sub {
    $imap{$_} = $conv->convert($_);
}, 'music');

runrun $Bin.'/../src/convmvfs', '-o', =>
    'srcdir=music,allow_other,ocharset=gb18030', 'music.gb18030';

sub tfork{
    unless(fork){
        for (1..100){
            -d 'music.gb18030/'.$imap{$_} || die "failed : $_\n" for keys %imap;
        }
        exit 0;
    }
}

for (1..10){
    tfork for 1..100;

    print '.';
    () while wait != -1;
}
print "\n";

runrun 'fusermount', '-u', 'music.gb18030';
runrun 'rm', '-rf', 'music';
rmdir 'music.gb18030';