#!/usr/bin/perl

##################################################
#
# GiantDisc mp3 Jukebox
# 
# © 2000, Rolf Brugger
#
##################################################


# gdinfo: Prints requested informations. This command is usually called
#         from remotely (command rsh)
# Options:
#   -d n        GiantDisc, get music directory.
#               Returns the first music directory with n MBytes free space.
#   -s file     Size of file in bytes
#   -m file     Modification date of file (seconds since epoch)

use lib '/home/music/bin';
use gdgentools;

if    ($#ARGV == 1  && $ARGV[0] eq "-d"){
  print gdparams::gdbase()."/".gdgentools::get_ripdirectory($ARGV[1])."\n";
}

elsif ($#ARGV == 1  && $ARGV[0] eq "-s"){
  my @flist = glob $ARGV[1];
  if (scalar(@flist)>0){
    my @fstat = stat ($flist[0]);
    print $fstat[7];
  }
  else{ 
    print "0";
  }
}

elsif ($#ARGV == 1  && $ARGV[0] eq "-m"){
  my @flist = glob $ARGV[1];
  if (scalar(@flist)>0){
    my @fstat = stat ($flist[0]);
    print $fstat[9];
  }
  else{ 
    print "0";
  }
}
else{
  print "gdgetmdir.pl n\n\n";
  print "GiantDisc, get music directory\n";
  print "Returns the first music directory with n MBytes free space\n";
}

#
