Skip to content

Commit 3f0cedf

Browse files
committed
fix path printing issues with windows
1 parent 03d9792 commit 3f0cedf

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/createFilename.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@
5353
cfg = setFilenames(cfg);
5454

5555
talkToMe(cfg, sprintf('\nData will be saved in this directory:\n\t%s\n', ...
56-
fullfile(cfg.dir.outputSubject, cfg.fileName.modality)));
56+
pathToPrint(fullfile(cfg.dir.outputSubject, ...
57+
cfg.fileName.modality))));
5758

58-
talkToMe(cfg, sprintf('\nData will be saved in this file:\n\t%s\n', cfg.fileName.events));
59+
talkToMe(cfg, sprintf('\nData will be saved in this file:\n\t%s\n', ...
60+
pathToPrint(cfg.fileName.events)));
5961

6062
if cfg.eyeTracker.do
6163

6264
talkToMe(cfg, sprintf('\nEyetracking data will be saved in this directory:\n\t%s\n', ...
63-
fullfile(cfg.dir.outputSubject, 'eyetracker')));
65+
pathToPrint(fullfile(cfg.dir.outputSubject, ...
66+
'eyetracker'))));
6467

6568
talkToMe(cfg, sprintf('\nEyetracking data will be saved in this file:\n\t%s\n', ...
66-
cfg.fileName.eyetracker));
69+
pathToPrint(cfg.fileName.eyetracker)));
6770

6871
end
6972

src/utils/pathToPrint.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function pth = pathToPrint(pth)
2+
%
3+
% Replaces single '\' by '/' on Windows
4+
% to prevent escaping warning when printing a path
5+
%
6+
% :param pth: If pth is a cellstr of paths, pathToPrint will work
7+
% recursively on it.
8+
% :type pth: char or cellstr
9+
%
10+
% (C) Copyright 2021 CPP_BIDS developers
11+
12+
if isunix()
13+
return
14+
end
15+
16+
if ischar(pth)
17+
pth = strrep(pth, '\', '/');
18+
19+
elseif iscell(pth)
20+
for i = 1:numel(pth)
21+
pth{i} = pathToPrint(pth{i});
22+
end
23+
end
24+
25+
end

0 commit comments

Comments
 (0)