app/Tree.php
public function importGedcomFile(StreamInterface $stream, string $filename): void
    {
        // Read the file in blocks of roughly 64K. Ensure that each block
        // contains complete gedcom records. This will ensure we don’t split
        // multi-byte characters, as well as simplifying the code to import
        // each block.

        $file_data = '';

        $this->deleteGenealogyData((bool) $this->getPreference('keep_media'));
        $this->setPreference('gedcom_filename', $filename);
        $this->setPreference('imported', '0');

        while (!$stream->eof()) {
            $file_data .= $stream->read(65536);
            // There is no strrpos() function that searches for substrings :-(
            for ($pos = strlen($file_data) - 1; $pos > 0; --$pos) {
                if ($file_data[$pos] === '0' && ($file_data[$pos - 1] === "\n" || $file_data[$pos - 1] === "\r")) {
                    // We’ve found the last record boundary in this chunk of data
                    break;
                }
            }
            if ($pos) {
                DB::table('gedcom_chunk')->insert([
                    'gedcom_id'  => $this->id,
                    'chunk_data' => substr($file_data, 0, $pos),
                ]);

                $file_data = substr($file_data, $pos);
            }
        }
        DB::table('gedcom_chunk')->insert([
            'gedcom_id'  => $this->id,
            'chunk_data' => $file_data,
        ]);

        $stream->close();
    }
public function importGedcomFile(StreamInterface $stream, string $filename): void
    {
        // Read the file in blocks of roughly 64K. Ensure that each block
        // contains complete gedcom records. This will ensure we don’t split
        // multi-byte characters, as well as simplifying the code to import
        // each block.

        $file_data = '';

        $this->deleteGenealogyData((bool) $this->getPreference('keep_media'));
        $this->setPreference('gedcom_filename', $filename);
        $this->setPreference('imported', '0');

        while (!$stream->eof()) {
            $file_data .= $stream->read(65536);
            // There is no strrpos() function that searches for substrings :-(
            for ($pos = strlen($file_data) - 1; $pos > 0; --$pos) {
                if ($file_data[$pos] === '0' && ($file_data[$pos - 1] === "\n" || $file_data[$pos - 1] === "\r")) {
                    // We’ve found the last record boundary in this chunk of data
                    break;
                }
            }
            if ($pos) {
                DB::table('gedcom_chunk')->insert([
                    'gedcom_id'  => $this->id,
                    'chunk_data' => substr($file_data, 0, $pos),
                ]);

                $file_data = substr($file_data, $pos);
            }
        }
        DB::table('gedcom_chunk')->insert([
            'gedcom_id'  => $this->id,
            'chunk_data' => $file_data,
        ]);

        $stream->close();
    }
public function importGedcomFile ( StreamInterface $ stream , string $ filename ) : void { // Read the file in blocks of roughly 64K. Ensure that each block // contains complete gedcom records. This will ensure we don’t split // multi-byte characters, as well as simplifying the code to import // each block. $ file_data = '' ; $ this -> deleteGenealogyData ( ( bool ) $ this -> getPreference ( 'keep_media' ) ) ; $ this -> setPreference ( 'gedcom_filename' , $ filename ) ; $ this -> setPreference ( 'imported' , '0' ) ; while ( ! $ stream -> eof ( ) ) { $ file_data .= $ stream -> read ( 65536 ) ; // There is no strrpos() function that searches for substrings :-( for ( $ pos = strlen ( $ file_data ) - 1 ; $ pos > 0 ; -- $ pos ) { if ( $ file_data [ $ pos ] === '0' && ( $ file_data [ $ pos - 1 ] === "\n" || $ file_data [ $ pos - 1 ] === "\r" ) ) { // We’ve found the last record boundary in this chunk of data break ; } } if ( $ pos ) { DB :: table ( 'gedcom_chunk' ) -> insert ( [ 'gedcom_id' => $ this -> id , 'chunk_data' => substr ( $ file_data , 0 , $ pos ) , ] ) ; $ file_data = substr ( $ file_data , $ pos ) ; } } DB :: table ( 'gedcom_chunk' ) -> insert ( [ 'gedcom_id' => $ this -> id , 'chunk_data' => $ file_data , ] ) ; $ stream -> close ( ) ; }
Import data from a gedcom file into this tree.

@param StreamInterface $stream   The GEDCOM file.
@param string          $filename The preferred filename, for export/download.

@return void
Import data from a gedcom file into this tree .