Skip to content

Commit f40ecf4

Browse files
committed
[bug] fix inconsistent function names for zstd and fopen handling
1 parent 96da116 commit f40ecf4

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

‎jdlink.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
else
100100
rawdata = urlread(uripath);
101101
fid = fopen(fname, 'wb');
102-
if (fid == 0)
102+
if (fid == -1)
103103
error('can not save URL to cache at path %s', fname);
104104
end
105105
fwrite(fid, uint8(rawdata));

‎savenifti.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
end
6767

6868
fid = fopen(filename, 'wb');
69-
if (fid == 0)
69+
if (fid == -1)
7070
error('can not write to the specified file');
7171
end
7272
fwrite(fid, buf);

‎zstdencode.m‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
function varargout = zstddecode(varargin)
1+
function varargout = zstdencode(varargin)
22
%
3-
% output = zstddecode(input)
3+
% output = zstdencode(input)
44
% or
5-
% output = zstddecode(input,info)
5+
% [output, info] = zstdencode(input)
6+
%
7+
% Compress a string or a numerical array using Zstd-compression
68
%
7-
% Decompressing an Zstd-compressed byte-stream to recover the original data
89
% This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)
910
%
1011
% authors:Qianqian Fang (q.fang <at> neu.edu)
1112
%
1213
% input:
13-
% input: a string, int8/uint8 vector or numerical array to store Zstd-compressed data
14-
% info (optional): a struct produced by the zmat/zstdencode function during
15-
% compression; if not given, the inputs/outputs will be treated as a
16-
% 1-D vector
14+
% input: the original data, can be a string, a numerical vector or array
1715
%
1816
% output:
19-
% output: the decompressed byte stream stored in a uint8 vector; if info is
20-
% given, output will restore the original data's type and dimensions
17+
% output: the compressed byte stream stored in a uint8 vector
18+
% info: (optional) a struct storing the metadata of the input, see "help zmat" for details
2119
%
2220
% examples:
2321
% [bytes, info]=zstdencode(eye(10));
@@ -32,12 +30,10 @@
3230
if (nargin == 0)
3331
error('you must provide at least 1 input');
3432
end
33+
3534
if (exist('zmat', 'file') == 2 || exist('zmat', 'file') == 3)
36-
if (nargin > 1)
37-
[varargout{1:nargout}] = zmat(varargin{1}, varargin{2:end});
38-
else
39-
[varargout{1:nargout}] = zmat(varargin{1}, 0, 'zstd', varargin{2:end});
40-
end
35+
[varargout{1:nargout}] = zmat(varargin{1}, 1, 'zstd', varargin{2:end});
36+
return
4137
else
4238
error('you must install ZMat toolbox to use this feature: http://github.com/NeuroJSON/zmat');
4339
end

0 commit comments

Comments
 (0)