Subversion Repositories DevTools

Rev

Rev 257 | Rev 283 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 257 Rev 261
Line 23... Line 23...
23
#                    StripExt                   - Return dir + file
23
#                    StripExt                   - Return dir + file
24
#                    StripFile                  - Returns extension
24
#                    StripFile                  - Returns extension
25
#                    StripFileExt               - Returns directory
25
#                    StripFileExt               - Returns directory
26
#                    StripDirExt                - Returns filename ( with optional ext)
26
#                    StripDirExt                - Returns filename ( with optional ext)
27
#                    CleanDirName               - Clean up a path
27
#                    CleanDirName               - Clean up a path
-
 
28
#                    TouchFile                  - Touch a file
-
 
29
#                    FileIsNewer                - Test if newer
28
#                    DisplayPath                - Genate a Path that can be displayed
30
#                    DisplayPath                - Genate a Path that can be displayed
-
 
31
#                    FileCreate                 - Create a simple text file
-
 
32
#                    FileAppend                 - Append to a simple text file
29
#
33
#
30
#
34
#
31
#......................................................................#
35
#......................................................................#
32
 
36
 
33
use 5.006_001;
37
use 5.006_001;
Line 66... Line 70...
66
                CleanDirName
70
                CleanDirName
67
                TouchFile
71
                TouchFile
68
                FileIsNewer
72
                FileIsNewer
69
                DisplayPath
73
                DisplayPath
70
                TruePath
74
                TruePath
-
 
75
                FileCreate
-
 
76
                FileAppend
71
 
77
 
72
                $ScmPathSep
78
                $ScmPathSep
-
 
79
                $ScmDirSep
73
                $Cwd
80
                $Cwd
74
                $CwdDrive
81
                $CwdDrive
75
                $ScmHost
82
                $ScmHost
76
            );
83
            );
77
#
84
#
78
# exported package globals go here
85
# exported package globals go here
79
#
86
#
80
our $ScmPathSep;                # Windows/Unix path seperator
87
our $ScmPathSep;                # Windows/Unix path seperator
-
 
88
our $ScmDirSep;                 # Windows/Unix dir sep
81
our $Cwd       ;                # Current directory ( no drive letter )
89
our $Cwd       ;                # Current directory ( no drive letter )
82
our $CwdFull   ;                # Current directory ( with drive letter )
90
our $CwdFull   ;                # Current directory ( with drive letter )
83
our $CwdDrive  ;                # Current drive
91
our $CwdDrive  ;                # Current drive
84
our $ScmHost   ;                # Host Type. Unix, WIN
92
our $ScmHost   ;                # Host Type. Unix, WIN
85
 
93
 
Line 106... Line 114...
106
 
114
 
107
    $isUnix = 1 if ( $ScmHost eq "Unix"  );
115
    $isUnix = 1 if ( $ScmHost eq "Unix"  );
108
    $isCygWin = 1 if ( $ENV{'SHELL'} || $ENV{'CYGWIN'} );
116
    $isCygWin = 1 if ( $ENV{'SHELL'} || $ENV{'CYGWIN'} );
109
 
117
 
110
    $ScmPathSep = $isUnix ? ':' : ';';     # Unix / Windows
118
    $ScmPathSep = $isUnix ? ':' : ';';     # Unix / Windows
-
 
119
    $ScmDirSep = $isUnix ? '/' : '\\';     # Unix / Windows
111
}
120
}
112
 
121
 
113
#-------------------------------------------------------------------------------
122
#-------------------------------------------------------------------------------
114
# Function        : InitFileUtils
123
# Function        : InitFileUtils
115
#
124
#
Line 163... Line 172...
163
    my $cwd = getcwd();
172
    my $cwd = getcwd();
164
    return $cwd;
173
    return $cwd;
165
}
174
}
166
 
175
 
167
#-------------------------------------------------------------------------------
176
#-------------------------------------------------------------------------------
168
# Function        : TouchFile
177
# Function        : TouchFile 
169
#
178
#
170
# Description     : touch a file
179
# Description     : touch a file
171
#                   Real use is to touch a marker file
180
#                   Real use is to touch a marker file
172
#
181
#
173
# Inputs          : path        - path to the file
182
# Inputs          : path        - path to the file
Line 218... Line 227...
218
    }
227
    }
219
    return $result;
228
    return $result;
220
}
229
}
221
 
230
 
222
#-------------------------------------------------------------------------------
231
#-------------------------------------------------------------------------------
-
 
232
# Function        : FileCreate
-
 
233
#                   FileAppend
-
 
234
#                   _FileWrite
-
 
235
#
-
 
236
# Description     : Simple Text File Creation function
-
 
237
#                   Suited to the creation of small, simple text files.
-
 
238
#
-
 
239
# Inputs          : Name of the file
-
 
240
#                   Remainder are:
-
 
241
#                       Lines of data to output to the file
-
 
242
#                       Or a reference to an array of lines
-
 
243
#                       Or a mixture
-
 
244
#                   All lines will be terminated with a "\n"
-
 
245
#
-
 
246
# Returns         : Nothing
-
 
247
#
-
 
248
sub FileCreate
-
 
249
{
-
 
250
    _FileWrite ( '>', @_ );
-
 
251
}
-
 
252
 
-
 
253
sub FileAppend
-
 
254
{
-
 
255
    _FileWrite ( '>>', @_ );
-
 
256
}
-
 
257
 
-
 
258
sub _FileWrite
-
 
259
{
-
 
260
    my $mode = shift @_;
-
 
261
    my $name = shift @_;
-
 
262
 
-
 
263
    Error ("FileCreate: No file specified") unless ( $name );
-
 
264
    Error ("FileCreate: Path is directory") if ( -d $name );
-
 
265
 
-
 
266
    local ( *FN );
-
 
267
    open  (FN, $mode, $name ) || Error( "Cannot create file: $name", "Reason: $!" );
-
 
268
 
-
 
269
    foreach my $entry ( @_ ) {
-
 
270
        if ( ref ($entry ) eq 'ARRAY'  ) {
-
 
271
            print FN $_ . "\n" foreach  ( @$entry );
-
 
272
        } else {
-
 
273
            print FN $entry . "\n"
-
 
274
        }
-
 
275
    }
-
 
276
    close FN;
-
 
277
}
-
 
278
 
-
 
279
#-------------------------------------------------------------------------------
223
# Function        : FileIsNewer
280
# Function        : FileIsNewer
224
#
281
#
225
# Description     : Test two files to see if the files are newer
282
# Description     : Test two files to see if the files are newer
226
#
283
#
227
# Inputs          : file1
284
# Inputs          : file1