diff --git a/src/Header/Writer/VisualFoxproHeaderWriter.php b/src/Header/Writer/VisualFoxproHeaderWriter.php index d64eddd..0c8febb 100644 --- a/src/Header/Writer/VisualFoxproHeaderWriter.php +++ b/src/Header/Writer/VisualFoxproHeaderWriter.php @@ -17,6 +17,6 @@ protected function writeRest(Header $header): void parent::writeRest($header); - $this->fp->write(str_pad($header->backlist, 263)); + $this->fp->write(str_pad($header->backlist, 263, chr(0))); } } diff --git a/src/Memo/Creator/AbstractMemoCreator.php b/src/Memo/Creator/AbstractMemoCreator.php index aa740ab..9dab033 100644 --- a/src/Memo/Creator/AbstractMemoCreator.php +++ b/src/Memo/Creator/AbstractMemoCreator.php @@ -25,7 +25,7 @@ public static function getExtension(): string public function createFile(): string { $pi = pathinfo($this->table->filepath); - $memoFilepath = sprintf('%s/%s.%s', $pi['dirname'], $pi['filename'], self::getExtension()); + $memoFilepath = sprintf('%s/%s.%s', $pi['dirname'], $pi['filename'], $this->getExtension()); $stream = Stream::createFromFile($memoFilepath, 'wb+'); $this->writeHeader($stream); diff --git a/src/Memo/Creator/FoxProMemoCreator.php b/src/Memo/Creator/FoxProMemoCreator.php new file mode 100644 index 0000000..7533929 --- /dev/null +++ b/src/Memo/Creator/FoxProMemoCreator.php @@ -0,0 +1,26 @@ +write(pack('N', 8)); //next block + + $stream->seek(4); + $stream->write(str_pad('', 2, chr(0))); //reserved + + $stream->seek(6); + $stream->write(pack('n', 64)); //Block size. 8 * 64 == 512, which will start records after the header + } +} diff --git a/src/Memo/Creator/MemoCreatorFactory.php b/src/Memo/Creator/MemoCreatorFactory.php index eb1653d..4ff48ee 100644 --- a/src/Memo/Creator/MemoCreatorFactory.php +++ b/src/Memo/Creator/MemoCreatorFactory.php @@ -22,6 +22,8 @@ public static function create(Table $table) case TableType::DBASE_7_MEMO: return new DBase7MemoCreator($table); //todo foxpro + case TableType::VISUAL_FOXPRO: + return new FoxProMemoCreator($table); default: throw new \Exception('Memo creator not realized for table version '.$table->getVersion()); } diff --git a/src/Memo/MemoFactory.php b/src/Memo/MemoFactory.php index c1e6839..42257e3 100644 --- a/src/Memo/MemoFactory.php +++ b/src/Memo/MemoFactory.php @@ -5,6 +5,7 @@ use XBase\DataConverter\Encoder\EncoderInterface; use XBase\Enum\TableType; use XBase\Table\Table; +use XBase\Memo\Creator\MemoCreatorFactory; class MemoFactory {