Merge pull request #1253 from jwillemsen/master
[ACE_TAO.git] / ACE / bin / ChangeLogEditor / FileLocatorFactory.pm
blob39e124c4ca92119f2319f3fc3db0f0f279cf2d44
1 package FileLocatorFactory;
3 # ************************************************************
4 # Description : Create FileLocator objects.
5 # Author : Chad Elliott
6 # Create Date : 11/29/2005
7 # ************************************************************
9 # ************************************************************
10 # Pragmas
11 # ************************************************************
13 use strict;
15 use Cwd;
16 use CVSFileLocator;
17 use SVNFileLocator;
19 # ************************************************************
20 # Subroutine Section
21 # ************************************************************
23 sub create {
24 ## Check for Subversion first. It is unlikely that the .svn directory
25 ## will exist when Subversion isn't the rcs being used. However, that
26 ## is not the case for CVS directories.
27 switch: {
28 ((defined $ENV{SVN_ASP_DOT_NET_HACK} && -d '_svn') || searchParentDirectory('.svn'))
29 && do { return new SVNFileLocator(); };
30 -d 'CVS' && do { return new CVSFileLocator(); };
31 print STDERR "WARNING: Unsupported revision control protocol\n";
34 return new FileLocator();
37 sub searchParentDirectory {
38 my($hidden) = shift;
39 my($path) = cwd();
40 my($index) = -1;
42 # Search all parent directories for the specified hidden
43 # directory. We stop when we either found the hidden directory
44 # of there are no more parent directories let to search.
45 do {
46 if (-d $path . '/' . $hidden) {
47 return 1;
50 $index = rindex($path, '/');
52 if ($index != -1) {
53 $path = substr ($path, 0, $index);
55 } while ($index != -1);
57 return 0;