xref: /AOO42X/main/helpcontent2/helpers/create_ilst.pl (revision 52b78ea2f0e0d1f4ec7f128eae59989e7fe366e3)
1cdf0e10cSrcweir:
2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3cdf0e10cSrcweir    if 0;
4*7e90fac2SAndrew Rist#**************************************************************
5cdf0e10cSrcweir#
6*7e90fac2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
7*7e90fac2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
8*7e90fac2SAndrew Rist#  distributed with this work for additional information
9*7e90fac2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
10*7e90fac2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
11*7e90fac2SAndrew Rist#  "License"); you may not use this file except in compliance
12*7e90fac2SAndrew Rist#  with the License.  You may obtain a copy of the License at
13cdf0e10cSrcweir#
14*7e90fac2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
15cdf0e10cSrcweir#
16*7e90fac2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
17*7e90fac2SAndrew Rist#  software distributed under the License is distributed on an
18*7e90fac2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19*7e90fac2SAndrew Rist#  KIND, either express or implied.  See the License for the
20*7e90fac2SAndrew Rist#  specific language governing permissions and limitations
21*7e90fac2SAndrew Rist#  under the License.
22cdf0e10cSrcweir#
23*7e90fac2SAndrew Rist#**************************************************************
24*7e90fac2SAndrew Rist
25*7e90fac2SAndrew Rist
26cdf0e10cSrcweir
27cdf0e10cSrcweir# creates the ilst control file for the
28cdf0e10cSrcweir# help specific images
29cdf0e10cSrcweir
30cdf0e10cSrcweiruse File::Find;
31cdf0e10cSrcweir
32cdf0e10cSrcweir$params = join "|", "",@ARGV,"";
33cdf0e10cSrcweir($params =~ /-dir/) ? ($startdir = $params) =~ (s/.*-dir=([^\|]*).*$/$1/gs) : (($startdir = `pwd`) =~ s/\n//gs);
34cdf0e10cSrcweir($params =~ /-pre/) ? ($pre = $params) =~ (s/.*-pre=([^\|]*).*$/$1/gs) : ($pre = "helpimg");
35cdf0e10cSrcweir
36cdf0e10cSrcweirmy $startdir_regexp = quotemeta($startdir);
37cdf0e10cSrcweir
38cdf0e10cSrcweir
39cdf0e10cSrcweirif ( -d $startdir ) {
40cdf0e10cSrcweir    find(sub{push @files, $File::Find::name if (($File::Find::name=~/\.png$/));},$startdir);
41cdf0e10cSrcweir    foreach ( @files ) { s#.*$startdir_regexp[\\/]##; };
42cdf0e10cSrcweir    for (sort(@files)) {
43cdf0e10cSrcweir        print "%GLOBALRES%/$pre/$_\n";
44cdf0e10cSrcweir    }
45cdf0e10cSrcweir} else {
46cdf0e10cSrcweir    &terminate("Cannot find $startdir.");
47cdf0e10cSrcweir}
48cdf0e10cSrcweir
49cdf0e10cSrcweir
50cdf0e10cSrcweirsub terminate {
51cdf0e10cSrcweir    $err = shift;
52cdf0e10cSrcweir    printf STDERR "$err\n\n";
53cdf0e10cSrcweir    $msg = <<"MSG";
54cdf0e10cSrcweircreate_ilst.pl -dir=directory [-pre=string]
55cdf0e10cSrcweir-dir  root directory for the help images to
56cdf0e10cSrcweir    be searched (default=current dir)
57cdf0e10cSrcweir    Only *.png will be found.
58cdf0e10cSrcweir-pre  define directory prefix (default=helpimg)
59cdf0e10cSrcweir
60cdf0e10cSrcweirMSG
61cdf0e10cSrcweir    die "$msg\n";
62cdf0e10cSrcweir}
63