App-SeismicUnixGui

 view release on metacpan or  search on metacpan

lib/App/SeismicUnixGui/misc/manage_files_by.pm  view on Meta::CPAN


	system(
		"                       			\\
                rm  $$ref_directory_path/$$ref_filename      	\\
        "
	);

}

sub is_file_empty {
	my ($ref_file) = shift @_;

	# default situation is to have a file that is empty
	my $answer = 1;

	# find status of file to see whether it is empty
	#$fsize[1] = (stat($$ref_file))[2];
	#print("\nfile is: $$ref_file\n");

	# -s is for size
	#verified by JL
	my $j = ( -s $$ref_file );

	#	print ("file: $$ref_file is $j in size\n\n");
	if ( -s $$ref_file > 0 ) {

		#		print  ("file is not empty\n\n") ;
		$answer = 0;
	}

	#	print("is file empty 1-yes 0-no---- $answer\n\n");
	#	print("file name for size is $$ref_file \n\n");
	#	answer=1 if empty and =0 if not empty

	return ($answer);
}

sub does_file_exist {
	my ($ref_file) = shift @_;

	# default situation is to have a file non-existent
	my $answer = 0;

	# -e returns 1 or ''
	#verified by JL
	#	print("file for exist test is $$ref_file\n\n");
	if ( -e $$ref_file ) {

		#	   print  ("file existence verified\n\n") ;
		$answer = 1;
	}

	#	answer=1 if existent and =0 if non-existent
	#verified by JL
	return ($answer);
}

sub is_one {

	# find out if a special file's content ==1
	# thereby verifying the existence of a second file
	my ($ref_file) = shift @_;

	# default situation is to have a file that is empty
	my $answer = 0;
	my $line;

	#print ("\nFor is_one the input file is called $$ref_file\n");

	# open the file of interest
	open( FILE, $$ref_file ) || print("Can't open file_name, $!\n");

	# read contents of file
	while ( $line = <FILE> ) {
		chomp($line);
		my ($x) = $line;

		if ( $x == 1 ) {
			$answer = 1;

			#print (" yes, first line is one\n\n");
		}
	}
	close(FILE);

	#	answer=1 if line=1  and =0 if line=0
	return ($answer);
}

sub is_zero {

	# find out if a special file's content ==0
	# thereby showing a second file does not exist
	my ($ref_file) = shift @_;

	# default situation is not to have a file with a zero on the first line
	my $answer = 0;
	my $line;

	#print ("\nFor is_zero the input file is called $$ref_file\n");

	# open the file of interest
	open( FILE, $$ref_file ) || print("Can't open file_name, $!\n");

	# read contents of file
	while ( $line = <FILE> ) {
		chomp($line);
		my ($x) = $line;

		if ( $x == 0 ) {
			$answer = 1;

			#print (" yes, first line is zero\n\n");
		}
	}
	close(FILE);

	#	answer=1 if line=1  =0
	#       answer=0 if line1 Not equal to 0
	return ($answer);
}



( run in 0.634 second using v1.01-cache-2.11-cpan-39bf76dae61 )