#!/usr/local/bin/perl 
#
#######################################################################
# This software has been created by Genome Research Limited (GRL).    # 
# GRL hereby grants permission to use, copy, modify and distribute    # 
# this software and its documentation for non-commercial purposes     # 
# without fee at the user's own risk on the basis set out below.      #
# GRL neither undertakes nor accepts any duty whether contractual or  # 
# otherwise in connection with the software, its use or the use of    # 
# any derivative, and makes no representations or warranties, express #
# or implied, concerning the software, its suitability, fitness for   #
# a particular purpose or non-infringement.                           #
# In no event shall the authors of the software or GRL be responsible # 
# or liable for any loss or damage whatsoever arising in any way      # 
# directly or indirectly out of the use of this software or its       # 
# derivatives, even if advised of the possibility of such damage.     #
# Our software can be freely distributed under the conditions set out # 
# above, and must contain this copyright notice.                      #
#######################################################################
#
# Written by apm - 28-7-97  
#
# Module to be called by other
# production software to ascertain if 
# any required project directories have
# been nearlined and are not yet restored. 
#
# $Id: nearline.pm,v 1.7 1998/06/08 10:45:29 apm Exp $
#
# $Log: nearline.pm,v $
# Revision 1.7  1998/06/08  10:45:29  apm
# Can't believe the way I looked for .nearlined!!! Changed
# it to be sensible!
#
# Revision 1.6  1997/12/08  17:26:04  apm
# Major change to allow automation of restore.
#
# Revision 1.5  1997/08/15  09:27:27  apm
# Change of filename to indicate nearlining of project.
#
# Revision 1.4  1997/08/11  12:26:09  apm
# No warn for asp.
#
# Revision 1.3  1997/07/29  13:47:14  apm
# Removed debugging/chdir'ing!
#
# Revision 1.2  1997/07/28  17:26:59  apm
# Returns to directory module called from.
#
# Revision 1.1  1997/07/28  14:30:47  apm
# Initial revision
#
#

$0 ='nearline.pm';

###################################################
# Called with name of calling program followed by
# appropriate directories to check (full path).  
###################################################

sub nearlined {

    my @dirs = @_;

    my ( $dir, $filename, $source, @nearline, $bailout, $nearlinefile );

    $source = shift @dirs;

    unless ( $#dirs >= 0 ) { warn "\n\t$source: No directories passed to $0\n\tPlease contact bug\n\n"; }

    foreach $dir ( @dirs ) {
	
	$nearlinefile = "$dir/.nearlined";

	if ( -e "$nearlinefile" ){
	    push(@nearline, $dir);
	    $bailout = 1;
	}

    }

    if ( $source eq 'asp' ) {

	if (defined ($bailout)) { return 1; }
	else { return 0;}
    }

    else { return @nearline; }

}
