Merge pull request #224 from DOCGroup/jwillemsen-patch-1
[MPC.git] / modules / WinProjectBase.pm
blob77a83f8c183f790f999ae92898ce12b420e25f52
1 package WinProjectBase;
3 # ************************************************************
4 # Description : A Windows base module for Project Creators
5 # Author : Chad Elliott
6 # Create Date : 1/4/2005
7 # ************************************************************
9 # ************************************************************
10 # Pragmas
11 # ************************************************************
13 use strict;
14 use WinPropertyBase;
16 use vars qw(@ISA);
17 @ISA = qw(WinPropertyBase);
19 # ************************************************************
20 # Data Section
21 # ************************************************************
23 my $max_win_env = 'MPC_MAX_WIN_FILE_LENGTH';
25 # ************************************************************
26 # Subroutine Section
27 # ************************************************************
29 sub convert_slashes {
30 #my $self = shift;
31 return 1;
35 sub case_insensitive {
36 #my $self = shift;
37 return 1;
41 sub translate_directory {
42 my($self, $dir) = @_;
44 ## Call the base class version
45 $dir = $self->DirectoryManager::translate_directory($dir);
47 ## Change drive letters and $() macros
48 $dir =~ s/^([A-Z]):/$1/i;
49 $dir =~ s/\$\(([^\)]+)\)/$1/g;
51 ## We need to make sure that we do not exceed the maximum file name
52 ## limitation (including the cwd (- c:\) and object file name). So, we
53 ## check the total length against a predetermined "acceptable" value.
54 ## This acceptable value is modifiable through the environment.
55 my $maxenv = $ENV{$max_win_env};
56 my $maxlen = (defined $maxenv && $maxenv =~ /^\d+$/ ? $maxenv : 128) + 3;
57 my $dirlen = length($dir);
58 my $diff = (length($self->getcwd()) + $dirlen + 1) - $maxlen;
60 if ($diff > 0) {
61 if ($diff > $dirlen) {
62 $dir = substr($dir, $dirlen - 1);
64 else {
65 $dir = substr($dir, $diff);
67 while($dir =~ s/^\\//) {
71 return $dir;
75 sub validated_directory {
76 my($self, $dir) = @_;
78 ## $(...) could contain a drive letter and Windows can not
79 ## make a directory that resembles a drive letter. So, we have
80 ## to exclude those directories with $(...).
81 if ($dir =~ /\$\([^\)]+\)/ || $dir =~ /\.\.\\/ || $dir =~ /^[A-Z]:/i) {
82 return '.';
84 else {
85 return $dir;
90 sub crlf {
91 return $_[0]->windows_crlf();
95 sub get_cmdsep_symbol {
96 #my $self = shift;
97 return '&';
101 sub file_sorter {
102 #my $self = shift;
103 #my $left = shift;
104 #my $right = shift;
105 return lc($_[1]) cmp lc($_[2]);