- <?php
-
- /*
- * We only require reading output files during a test run for a client.
- * The backup thread does not delete test files because it is assumed that the client will
- * need the file contents during and after the test is complete.
- *
- */
- include_once "../shd/backup-funcs.php";
-
- $open_files = array(); //files are indexed on their backup-id
-
-
- /*
- * Get or open a file reader. Returns null if the file does not exist.
- *
- * $dataLoc: the location of the file
- * $buid: the backup ID
- */
- function getObject_outputFile( $dataLoc, $buid ){
-
- global $open_files;
-
- if( !array_key_exists( $buid, $open_files) ){
- $fn = getFilename_out( $buid, true, false );
- $ffn = "$dataLoc/$fn";
- if( !file_exists( $ffn ) ) return null;
- $file = new SplFileObject( $ffn, 'r' );
- $open_files[ $buid ] = $file;
- }
- return $open_files[$buid];
-
- }
-
- function closeFile( $buid ){
-
- global $open_files;
-
- print("Closed output file for backup($buid)\n");
-
- if( !array_key_exists( $buid, $open_files) ) return 0;
- unset( $open_files[ $buid ] );
-
- }
-
- /**
- * Return the file data starting from the $lineNum given.
- *
- * Return the number of lines read.
- *
- * $lineData: (out) Data as a single string.
- */
- function getLinesFrom( $objFile, $lineNum, &$lineData ){
-
- $lineData = '';
- $cnt=0;
-
- $objFile->seek( $lineNum );
-
- while (!$objFile->eof()) {
- $cnt++;
- $lineData .= $objFile->fgets();
- }
- return $cnt;
- }
-
- ?>