File: file_mode.pl

package info (click to toggle)
tct 1.07-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,828 kB
  • ctags: 1,128
  • sloc: perl: 9,604; ansic: 4,861; makefile: 516; sh: 77
file content (23 lines) | stat: -rw-r--r-- 414 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#  This retrieves a possibly cached mode on file.
# If it returns "BOGUS", it means that the stat failed.
#
# tchrist@convex.com

package main;
require 'stat.pl';

package file_mode;

sub main'Mode {
    local($file) = @_;

    if (!defined $modes{$file}) {
       if (&'Stat($file)) {
           $modes{$file} = $'st_mode;
       } else {
           $modes{$file} = 'BOGUS';
       }
    }
    $modes{$file};
}