updated git and svn scripts
[xrzperl.git] / epub_manifest_add
blobb2619c97ac010662776e92ec28fc9c64034f0388
1 #!/usr/bin/perl -w
2 ###APPNAME: epub_manifest_add
3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Wed Apr 28 01:12:41 2010
5 ###APPVER: 0.1
6 ###APPDESC: epub_manifest_add
7 ###APPUSAGE:
8 ###APPEXAMPLE: epub_manifest_add
9 ###APPOPTION:
10 use strict;
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
14 #OR nothing will work
15 use lib $ENV{XR_PERL_MODULE_DIR};
17 use MyPlace::Script::Usage qw/help_required help_even_empty/;
18 exit 0 if(help_required($0,@ARGV));
19 #exit 0 if(help_even_empty($0,@ARGV));
21 use File::Glob qw/bsd_glob/;
22 use MyPlace::Epub qw/get_media_type get_file_id/;
25 sub print_item {
26 my $item=shift;
27 my $id = get_file_id($item);
28 my $type = get_media_type($item);
29 if($type) {
30 print "<item id=\"$id\" href=\"$item\" media-type=\"$type\"/>\n";
34 sub get_item {
35 my $path = shift;
36 my $glob_exp;
37 my @result;
38 if($path) {
39 $glob_exp = "$path/*";
41 else {
42 $glob_exp = "*";
44 foreach my $filename (bsd_glob($glob_exp)) {
45 if(-d $filename) {
46 push @result,&get_item($filename);
48 elsif(-f $filename) {
49 push @result,$filename;
52 return @result;
55 if(@ARGV) {
56 foreach my $path (@ARGV) {
57 print_item($_) foreach(get_item($path));
60 else {
61 print_item($_) foreach(get_item());