2 # Returns a list of files and directories under some directory
4 $trust_unknown_referers = 1;
5 require './bacula-backup-lib.pl';
7 print "Content-type: text/plain\n\n";
9 # Get the parent directory ID
10 $dbh = &connect_to_database();
11 $cmd = $dbh->prepare("select PathId from Path where Path = ?");
12 $d = $in{'dir'} eq "/" ? "/" : $in{'dir'}."/";
13 $wind = &unix_to_dos($d);
15 ($pid) = $cmd->fetchrow();
18 if ($in{'job'} ne "") {
19 $jobsql = "and Job.JobId = $in{'job'}";
23 # Search just within one volume
24 # Subdirectories of directory, that are on this volume
25 $cmd1 = $dbh->prepare("
27 from Path, File, Job, JobMedia, Media
28 where File.PathId = Path.PathId
29 and File.JobId = Job.JobId
30 and Job.JobId = JobMedia.JobId
31 and JobMedia.MediaId = Media.MediaId
32 and Media.VolumeName = ?
35 $cmd1->execute($in{'volume'}) || die "db error : ".$dbh->errstr;
36 while(($f) = $cmd1->fetchrow()) {
37 $f = &dos_to_unix($f);
38 if ($f =~ /^(\Q$d\E[^\/]+\/)/) {
44 # Files in directory, that are on this volume
45 $cmd2 = $dbh->prepare("
47 from File, Filename, Job, JobMedia, Media
48 where File.FilenameId = Filename.FilenameId
50 and File.JobId = Job.JobId
51 and Job.JobId = JobMedia.JobId
52 and JobMedia.MediaId = Media.MediaId
53 and Media.VolumeName = ?
56 $cmd2->execute($pid, $in{'volume'}) || die "db error : ".$dbh->errstr;
57 while(($f) = $cmd2->fetchrow()) {
58 push(@rv, "$d$f") if ($f =~ /\S/);
64 # Subdirectories of directory
65 $cmd1 = $dbh->prepare("
68 where File.PathId = Path.PathId
69 and File.JobId = Job.JobId
72 $cmd1->execute() || die "db error : ".$dbh->errstr;
73 while(($f) = $cmd1->fetchrow()) {
74 $f = &dos_to_unix($f);
75 if ($f =~ /^(\Q$d\E[^\/]+\/)/) {
82 $cmd2 = $dbh->prepare("
84 from File, Filename, Job
85 where File.FilenameId = Filename.FilenameId
87 and File.JobId = Job.JobId
90 $cmd2->execute($pid) || die "db error : ".$dbh->errstr;
91 while(($f) = $cmd2->fetchrow()) {
92 push(@rv, "$d$f") if ($f =~ /\S/);