1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
package FileLocatorFactory;
# ************************************************************
# Description : Create FileLocator objects.
# Author : Chad Elliott
# Create Date : 11/29/2005
# $Id: FileLocatorFactory.pm 94999 2011-11-09 23:31:08Z hillj $
# ************************************************************
# ************************************************************
# Pragmas
# ************************************************************
use strict;
use Cwd;
use CVSFileLocator;
use SVNFileLocator;
# ************************************************************
# Subroutine Section
# ************************************************************
sub create {
## Check for Subversion first. It is unlikely that the .svn directory
## will exist when Subversion isn't the rcs being used. However, that
## is not the case for CVS directories.
switch: {
((defined $ENV{SVN_ASP_DOT_NET_HACK} && -d '_svn') || searchParentDirectory('.svn'))
&& do { return new SVNFileLocator(); };
-d 'CVS' && do { return new CVSFileLocator(); };
print STDERR "WARNING: Unsupported revision control protocol\n";
}
return new FileLocator();
}
sub searchParentDirectory {
my($hidden) = shift;
my($path) = cwd();
my($index) = -1;
# Search all parent directories for the specified hidden
# directory. We stop when we either found the hidden directory
# of there are no more parent directories let to search.
do {
if (-d $path . '/' . $hidden) {
return 1;
}
$index = rindex($path, '/');
if ($index != -1) {
$path = substr ($path, 0, $index);
}
} while ($index != -1);
return 0;
}
1;
|