Skip to content

Commit

Permalink
feat: Updated src/Snps/IO/Reader.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 12, 2024
1 parent 01570df commit ad09040
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Snps/IO/Reader.php
Expand Up @@ -62,7 +62,7 @@ public function read(): array
// var_dump($file);
if (is_string($file) && file_exists($file)) {
if (strpos($file, ".zip") !== false) {
$zip = new ZipArchive();
$zip = new ZipArchive(ZipArchive::RDONLY);
if ($zip->open($file) === true) {
$firstEntry = $zip->getNameIndex(0);
$firstEntryFile = $zip->getStream($firstEntry);
Expand All @@ -72,7 +72,7 @@ public function read(): array
}
} elseif (strpos($file, ".gz") !== false) {
$fileContents = file_get_contents($file);
$fileContents = gzdecode($fileContents);
$fileContents = zlib_decode($fileContents);

$read_data = $this->_extract_comments($fileContents);
$compression = "gzip";
Expand All @@ -84,7 +84,7 @@ public function read(): array
$fileContents = $file;
$read_data = $this->_handle_bytes_data($fileContents);

$tempfile = tmpfile();
$tempfile = fopen('php://temp', 'w+');
fwrite($tempfile, $fileContents);
$meta_data = stream_get_meta_data($tempfile);
$file_path = $meta_data['uri'];
Expand Down Expand Up @@ -263,6 +263,7 @@ private function readHelper($source, $parser)
{
$phased = false;
$build = 0;
$snps = [];

if ($this->_only_detect_source) {
$snps = array();
Expand Down Expand Up @@ -843,7 +844,7 @@ public function readGeneric(string $file, ?string $compression, int $skip = 1):
$parser = function () use ($file, $compression, $skip) {
$parse = function ($sep, $use_cols = false) use ($file, $skip, $compression) {
// Stream filter for compressed file, if needed
$filter = $compression ? 'compress.zlib://' : '';
$filter = $compression === "gzip" ? 'compress.zlib://' : '';


// CSV Reader setup
Expand Down

0 comments on commit ad09040

Please sign in to comment.