Subversion Repositories gelsvn

Rev

Rev 217 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 bj 1
package WinProjectBase;
2
 
3
# ************************************************************
4
# Description   : A Windows base module for Project Creators
5
# Author        : Chad Elliott
6
# Create Date   : 1/4/2005
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
 
15
# ************************************************************
217 bj 16
# Data Section
17
# ************************************************************
18
 
19
my($max_win_env) = 'MPC_MAX_WIN_FILE_LENGTH';
20
 
21
# ************************************************************
107 bj 22
# Subroutine Section
23
# ************************************************************
24
 
217 bj 25
sub convert_slashes {
26
  #my($self) = shift;
27
  return 1;
28
}
29
 
30
 
31
sub case_insensitive {
32
  #my($self) = shift;
33
  return 1;
34
}
35
 
36
 
37
sub translate_directory {
38
  my($self) = shift;
39
  my($dir)  = shift;
40
 
41
  ## Call the base class version
42
  $dir = $self->DirectoryManager::translate_directory($dir);
43
 
44
  ## Change drive letters and $() macros
45
  $dir =~ s/^([A-Z]):/$1/i;
46
  $dir =~ s/\$\(([^\)]+)\)/$1/g;
47
 
48
  ## We need to make sure that we do not exceed the maximum file name
49
  ## limitation (including the cwd (- c:\) and object file name).  So, we
50
  ## check the total length against a predetermined "acceptable" value.
51
  ## This acceptable value is modifiable through the environment.
52
  my($maxenv) = $ENV{$max_win_env};
53
  my($maxlen) = (defined $maxenv && $maxenv =~ /^\d+$/ ? $maxenv : 128) + 3;
54
  my($dirlen) = length($dir);
55
  my($diff)   = (length($self->getcwd()) + $dirlen + 1) - $maxlen;
56
 
57
  if ($diff > 0) {
58
    if ($diff > $dirlen) {
59
      $dir = substr($dir, $dirlen - 1);
60
    }
61
    else {
62
      $dir = substr($dir, $diff);
63
    }
64
    while($dir =~ s/^\\//) {
65
    }
66
  }
67
 
68
  return $dir;
69
}
70
 
71
 
107 bj 72
sub validated_directory {
73
  my($self) = shift;
74
  my($dir)  = shift;
75
 
76
  ## $(...) could contain a drive letter and Windows can not
77
  ## make a directory that resembles a drive letter.  So, we have
78
  ## to exclude those directories with $(...).
79
  if ($dir =~ /\$\([^\)]+\)/ || $dir =~ /\.\.\\/ || $dir =~ /^[A-Z]:/i) {
80
    return '.';
81
  }
82
  else {
83
    return $dir;
84
  }
85
}
86
 
87
 
88
sub crlf {
89
  my($self) = shift;
90
  return $self->windows_crlf();
91
}
92
 
93
 
94
sub file_sorter {
217 bj 95
  #my($self)  = shift;
96
  #my($left)  = shift;
97
  #my($right) = shift;
98
  return lc($_[1]) cmp lc($_[2]);
107 bj 99
}
100
 
101
 
102
1;