⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lsparse.pl

📁 站点映像程序
💻 PL
📖 第 1 页 / 共 3 页
字号:
			if( $kind =~ /^d/ ) {				# a directory				$type = 'd';				$size = 0;   # Don't believe the report size			}			$currdir =~ s,/+,/,g;			$file =~ s,^/$match,,;			$file = "/$currdir/$file";			$file =~ s,/+,/,g;			return( substr( $file, 1 ), $size, $time, $type, $mode );		}		elsif( /^[dcbsp].*[^:]$/ || /^\s*$/ || /^[Tt]otal.*/ || /[Uu]nreadable$/ ){			;		}		elsif( /^.*[Uu]pdated.*:/ ){			# Probably some line like:			# Last Updated:  Tue Oct  8 04:30:50 EDT 1991			# skip it			next;		}		else {			printf( "Unmatched line: %s", $_ );		}	}	return( '', 0, 0, 0, 0 );}# Convert NetWare file access mode chars at the start of a DIR entry # into a Unix access number.sub netware_to_mode{	local( $kind ) = @_;	local( @kind, $c, $k );	# Ignore all but the mode characters inside []	$k = $kind;	$k =~ s,.*\[(.*)\].*,$1,;	@kind = split( //, $kind );	$mode = 0;		# init $mode to no access	foreach $c ( @kind ){		if( $c eq 'R' )	{$mode |= 0x644;}	## r/w r r		if( $c eq 'W' ) {$mode |= 0x222;}	## w   w w		if( $c eq 'F' ) {$mode |= 0x444;}	## r   r r		}	return $mode;}# --------------------- parse VMS dir output# for each file or directory line found return a tuple of# (pathname, size, time, type, mode)# pathname is a full pathname relative to the directory set by reset()# size is the size in bytes (this is always 0 for directories)# time is a Un*x time value for the file# type is "f" for a file, "d" for a directory and#         "l linkname" for a symlinksub lsparse'line_vms{	local( $fh ) = @_;	local( $non_crud, $perm_denied );	if( eof( $fh ) ){		return( "", 0, 0, 0 );	}	while( <$fh> ){		# Store listing		print main'STORE $_;		# Stomp on carriage returns		s/\015//g;		# I'm about to look at this at lot		study;		if( /^\s*$/ ){			next;		}		if( /^\s*Total of/i ){			# Just a size report ignore			next;		}		if( /\%RMS-E-PRV|insufficient privilege/i ){			# A permissions error - skip the line			next;		}		# Upper case is so ugly		if( ! $lsparse'vms_keep_case ){			tr/A-Z/a-z/;		}		# DISK$ANON:[ANONYMOUS.UNIX]		if( /^([^:]+):\[([^\]+]+)\]\s*$/ ){			# The directory name			# Use the Unix convention of /'s in filenames not			# .'s			$currdir = '/' . $2;			$currdir =~ s,\.,/,g;			$currdir =~ s,/+,/,g;			$currdir =~ s,^/$vms_strip,,;			if( $currdir eq '' ){				next;			}			$match = $currdir;			$match =~ s/([\+\(\)\[\]\*\?])/\\$1/g;#print ">>>match=$match currdir=$currdir\n";			return( substr( $currdir, 1 ), 0, 0, 'd', 0 );		}			# MultiNet FTP	# DSPD.MAN;1  9   1-APR-1991 12:55 [SG,ROSENBLUM] (RWED,RWED,RE,RE)	# CMU/VMS-IP FTP	# [VMSSERV.FILES]ALARM.DIR;1      1/3          5-MAR-1993 18:09		local( $dir, $file, $vers, $size, $lsdate, $got );		$got = 0;		# For now ignore user and mode		if( /^((\S+);(\d+))?\s+(\d+)\s+(\d+-\S+-\d+\s+\d+:\d+)/ ){			($file, $vers, $size, $lsdate) = ($2,$3,$4,$5);			$got = 1;		}		elsif( /^(\[([^\]]+)\](\S+);(\d+))?\s+\d+\/\d+\s+(\d+-\S+-\d+\s+\d+:\d+)\s*$/ ){			($dir,$file,$vers,$lsdate) = ($2,$3,$4,$5);			$got = 1;		}		# The sizes mean nothing under unix...		$size = 0;				if( $got ){			local( $time ) = &main'lstime_to_time( $lsdate );			local( $type ) = 'f';			local( $mode ) = 0444;			# Handle wrapped long filenames			if( $filename ne '' ){				$file = $filename;				$vers = $version;				if( $directory ){					$dir = $directory;				}			}			if( defined( $dir ) ){				$dir =~ s/\./\//g;				$file = $dir . '/' . $file;			}			$filename = '';			if( $file =~ /^(.*)\.dir(;\d+)?$/ ){				if( ! $vms_keep_dotdir ){					$file = $1 . $2;				}				$type = 'd';				$mode = 0555;			}			$lsparse'vers = $vers;#print "file=|$file| match=|$match| vms_strip=|$vms_strip|\n";			$file =~ s,^,/,;			$file =~ s,^/$match,,;			if( ! defined( $dir ) ){				$file = "$currdir/$file";			}			$file =~ s,^$vms_strip,,;			$file =~ s,/+,/,g;#print  "file=|$file|\n";			return( substr( $file, 1 ), $size, $time, $type, $mode );		}		elsif( /^\[([^\]]+)\](\S+);(\d+)\s*$/ ){			# If a filename is long then it is on a line by itself			# with the details on the next line			local( $d, $f, $v ) = ($1, $2, $3);			$d =~ s/\./\//g;			$directory = $d;			$filename = $f;			$version = $v;		}		elsif( /^(\S+);(\d+)\s*$/ ){			# If a filename is long then it is on a line by itself			# with the details on the next line			$filename = $1;			$version = $2;		}		else {			printf( "Unmatched line: %s", $_ );		}	}	return( '', 0, 0, 0, 0 );}# --------------------- parse output from dos ftp server# for each file or directory line found return a tuple of# (pathname, size, time, type, mode)# pathname is a full pathname relative to the directory set by reset()# size is the size in bytes (this is always 0 for directories)# time is a Un*x time value for the file# type is "f" for a file, "d" for a directory and#         "l linkname" for a symlinksub lsparse'line_dosftp{	local( $fh ) = @_;	while( 1 ){		if( $pending ){			$_ = $pending;			$pending = '';		}		else {			if( eof( $fh ) ){				return( "", 0, 0, 0 );			}			$_ = <$fh>;			# Store listing			print main'STORE $_;			# Ignore the summary at the end and blank lines			if( /^\d+ files?\./ || /^\s+$/ ){				next;			}		}		# Stomp on carriage returns		s/\015//g;		# I'm about to look at this at lot		study;		if( m|(\S+)\s+(\S+)?\s+(\d+):(\d+)\s+(\d+)/(\d+)/(\d+)\s*(.*)| ){			local( $file, $commasize, $hrs, $min, $mon, $day, $yr ) =				($1, $2, $3, $4, $5, $6, $7);			$pending = $8;			# TODO: fix hacky 19$yr			local( $lsdate ) = "$day-$mon-19$yr $hrs:$min";			local( $time ) = &main'lstime_to_time( $lsdate );			local( $type ) = '?';			local( $mode ) = 0;			local( $size ) = $commasize;			$size =~ s/,//g;			if( $file =~ m:(.*)/$: ){				$file = $1;				$type = 'd';					$size = 0;   # Don't believe the report size			}			else {				# (hopefully) a regular file				$type = 'f';			}						$currdir =~ s,/+,/,g;			$file =~ s,^/$match,,;			$file = "/$currdir/$file";			$file =~ s,/+,/,g;			return( substr( $file, 1 ), $size, $time, $type, $mode );		}		else {			printf( "Unmatched line: %s", $_ );		}	}	return( '', 0, 0, 0, 0 );}# --------------------- parse output from a slightly DOS-like dir command# for each file or directory line found return a tuple of# (pathname, size, time, type, mode)# pathname is a full pathname relative to the directory set by reset()# size is the size in bytes (this is always 0 for directories)# time is a Un*x time value for the file# type is "f" for a file, "d" for a directory and#         "l linkname" for a symlink# 03-16-94  06:29AM       <DIR>          .# 03-16-94  06:29AM       <DIR>          ..# 04-11-94  11:48PM       <DIR>          creative# 03-08-94  07:17AM                 5504 article.xfiles.intro# 02-28-94  11:44AM                 3262 article1.gillian.andersonsub lsparse'line_dosish{	local( $fh ) = @_;	while( 1 ){		if( eof( $fh ) ){			return( "", 0, 0, 0 );		}		$_ = <$fh>;		# Store listing		print main'STORE $_;		# Ignore blank lines		if( /^\s+$/ ){			next;		}		# Stomp on carriage returns		s/\015//g;		# I'm about to look at this at lot		study;		if( m,(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)(AM|PM)\s+(\d+|<DIR>)\s+(\S.*), ){			local( $mon, $day, $yr, $hrs, $min, $ampm, $dir_or_size, $file ) =				($1, $2, $3, $4, $5, $6, $7, $8);			if( $file eq '.' || $file eq '..' ){				next;			}			$hrs += 12 if $ampm =~ /PM/;			if( $hrs == 12 || $hrs == 24 ){				$hrs -= 12;			}			# TODO: fix hacky 19$yr			local( $lsdate ) = "$day-$mon-19$yr $hrs:$min";			local( $time ) = &main'lstime_to_time( $lsdate );			local( $type ) = ($dir_or_size eq '<DIR>' ? 'd' : 'f');			local( $mode ) = 0;			local( $size ) = 0;			$size = $dir_or_size if $dir_or_size =~ /^\d/;			$currdir =~ s,/+,/,g;			$file =~ s,^/$match,,;			$file = "/$currdir/$file";			$file =~ s,/+,/,g;			return( substr( $file, 1 ), $size, $time, $type, $mode );		}		# Match starts of directories.		elsif( /^([\.\/\\]*.*):$/ ){			$dir = $1;			# Switch from dos to unix slashes.			$dir =~ s,\\,/,g;			if( $dir eq '.' ){				next;			}			elsif( $dir !~ /^\// ){				$currdir = "$here/$dir";			}			else {				$currdir = "$dir";			}			$currdir =~ s,/+,/,g;			$match = $currdir;			$match =~ s/([\+\(\)\[\]\*\?])/\\$1/g;			return( substr( $currdir, 1 ), 0, 0, 'd', 0 );		}		else {			printf( "Unmatched line: %s", $_ );		}	}	return( '', 0, 0, 0, 0 );}# --------------------- parse output from supertcp ftp server# for each file or directory line found return a tuple of# (pathname, size, time, type, mode)# pathname is a full pathname relative to the directory set by reset()# size is the size in bytes (this is always 0 for directories)# time is a Un*x time value for the file# type is "f" for a file, "d" for a directory and#         "l linkname" for a symlink# .               <DIR>           11-16-94        17:16# ..              <DIR>           11-16-94        17:16# INSTALL         <DIR>           11-16-94        17:17# CMT             <DIR>           11-21-94        10:17# DESIGN1.DOC          11264      05-11-95        14:20# README.TXT            1045      05-10-95        11:01# WPKIT1.EXE          960338      06-21-95        17:01# CMT.CSV                  0      07-06-95        14:56# .               <DIR>           11/16/94        17:16# ..              <DIR>           11/16/94        17:16# INSTALL         <DIR>           11/16/94        17:17# CMT             <DIR>           11/21/94        10:17# DESIGN1.DOC          11264      05/11/95        14:20# README.TXT            1045      05/10/95        11:01# WPKIT1.EXE          960338      06/21/95        17:01# CMT.CSV                  0      07/06/95        14:56sub lsparse'line_supertcp{    local( $fh ) = @_;    while( 1 ) {	if( $pending ){	    $_ = $pending;	    $pending = '';	}	else {	    if( eof( $fh ) ){		return( "", 0, 0, 0 );	    }	    $_ = <$fh>;	    # Store listing	    print main'STORE $_;	    # Ignore the summary at the end and blank lines	    if( /^\d+ files?\./ || /^\s+$/ ){		next;	    }	}	# Stomp on carriage returns	s/\015//g;	s/\s+$//;               # I'm about to look at this at lot	study;	local( $file, $dirsize, $date, $time ) = split(" ", $_, 4);	local( $mon, $day, $yr ) = split ( /[-\/]/, $date, 3);	if( defined $file ){	    next if ( $file eq '..' || $file eq '.' );	    $pending = $5;	    local( $lsdate ) = "$day-$mon-$yr $time";	    local( $time ) = &main'lstime_to_time( $lsdate );            local( $type ) = '?';	    local( $mode ) = 0;            if ( $dirsize eq '<DIR>' ) {               $type = 'd';               $size = 0;            }            else {               $type = 'f';	       $size = $dirsize;	       $size =~ s/,//g;            }	    $currdir =~ s,/+,/,g;	    $file =~ s,^/$match,,;	    $file = "/$currdir/$file";	    $file =~ s,/+,/,g;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -