From 06ad37679fb068f4bbaaedcae6b32c9132fb560c Mon Sep 17 00:00:00 2001 From: "Michael Stumpf (ifhcluster)" Date: Tue, 10 Sep 2019 14:38:31 +0200 Subject: [PATCH] fixed extraction routine --- matlab/@ustar/ustar.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/matlab/@ustar/ustar.m b/matlab/@ustar/ustar.m index f9c8288..14ea097 100644 --- a/matlab/@ustar/ustar.m +++ b/matlab/@ustar/ustar.m @@ -106,28 +106,34 @@ classdef ustar < handle fname = obj.subFile; fsize = obj.subFileSize; end - function extract(obj,fname) + function extract(obj,fname,varargin) % obj.extract(fname) % Extracts the requested subfile to a standalone file. % Input % fname name of subfile + % ? outfile path of output file (default: fname) + par = inputParser; + addParamValue(par,'outfile',fname,@ischar); + parse(par,varargin{:}); + outfile = par.Results.outfile; + idx = obj.findSubfile(fname); fbeg = obj.subFileBeg(idx); fsize = obj.subFileSize(idx); - fidw = fopen(fname,'w'); + fidw = fopen(outfile,'w'); fseek(obj.fileID,fbeg,'bof'); % Chunk the file nchunk = ceil(fsize/obj.extrBuffSize); nchunkFull = floor(fsize/obj.extrBuffSize); nchunkPart = nchunk-nchunkFull; for ichunk=1:nchunkFull - buff = fread(obj.fileID,[1,obj.extrBuffSize],'char=>char'); - fwrite(fidw,buff,'char'); + buff = fread(obj.fileID,[1,obj.extrBuffSize],'*uint8'); + fwrite(fidw,buff); end if nchunkPart>0 sizeChunkPart = mod(fsize,obj.extrBuffSize); - buff = fread(obj.fileID,[1,sizeChunkPart],'char=>char'); - fwrite(fidw,buff,'char'); + buff = fread(obj.fileID,[1,sizeChunkPart],'*uint8'); + fwrite(fidw,buff); end fclose(fidw); end