]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Rename and move InitFileposition function.
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 22 Jan 2016 13:55:41 +0000 (14:55 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Fri, 22 Jan 2016 13:55:41 +0000 (14:55 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
modules/Base.pm

index fbda49ac76ebdf7fc21e1df36d47f4d2b4846e9d..2f5e73773bc825d21c6000d54d33cd2daba5f130 100644 (file)
@@ -6,35 +6,6 @@ use Exporter qw(import);
 
 our @EXPORT_OK = qw(GenerateMonitoredFiles FilePositions);
 
-#
-## Function for fileposition initialization.
-#
-## This function is used to get the cursor position of the end of file (EOF) of
-## a specified file.
-#
-## In order to prevent from permanently read and keep files opened, or dealing
-## with huge logfiles, at initialization time of the worker processes, the file will
-## be opened once and the cursor position of the end of file (EOF) get stored.
-#
-sub InitFileposition ($) {
-       my $file = $_[0];
-
-       # Open the file.
-       open(FILE, $file) or die "Could not open $file. $!";
-
-       # Just seek to the end of the file (EOF).
-       seek(FILE, 0, 2);
-
-       # Get and store the position.
-       my $position = tell(FILE),
-
-       # Close the file again.
-       close(FILE);
-
-       # Return the position.
-       return $position;
-}
-
 #
 ## Function to generate a hash of monitored files and their file positions.
 #
@@ -134,7 +105,7 @@ sub FilePositions (\%\%) {
                        $new_file_positions{$file} = $current_file_positions{$file};
                } else {
                        # Call function to obtain the file position.
-                       my $position = &InitFileposition($file);
+                       my $position = &_initFileposition($file);
 
                        # Add filename and position to the temporary hash.
                        $new_file_positions{$file} = $position;
@@ -145,4 +116,33 @@ sub FilePositions (\%\%) {
        return %new_file_positions;
 }
 
+#
+## Function for fileposition initialization.
+#
+## This function is used to get the cursor position of the end of file (EOF) of
+## a specified file.
+#
+## In order to prevent from permanently read and keep files opened, or dealing
+## with huge logfiles, at initialization time of the worker processes, the file will
+## be opened once and the cursor position of the end of file (EOF) get stored.
+#
+sub _initFileposition ($) {
+       my $file = $_[0];
+
+       # Open the file.
+       open(FILE, $file) or die "Could not open $file. $!";
+
+       # Just seek to the end of the file (EOF).
+       seek(FILE, 0, 2);
+
+       # Get and store the position.
+       my $position = tell(FILE),
+
+       # Close the file again.
+       close(FILE);
+
+       # Return the position.
+       return $position;
+}
+
 1;