Skip to content

Commit 9891ba1

Browse files
refactor: remove duplicate Docker import logic and prevent Windows batch generation in Docker (fixes #285)
1 parent 0467ce5 commit 9891ba1

2 files changed

Lines changed: 79 additions & 84 deletions

File tree

import_concore.m

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
function import_concore
2-
global concore;
3-
4-
try
5-
pid = getpid();
6-
catch exc
7-
pid = feature('getpid');
8-
end
9-
outputpid = fopen('concorekill.bat','w');
10-
fprintf(outputpid,'%s',['taskkill /F /PID ',num2str(pid)]);
11-
fclose(outputpid);
12-
13-
14-
try
15-
iportfile = fopen('concore.iport');
16-
concore.iports = fscanf(iportfile,'%c');
17-
catch exc
18-
iportfile = '';
19-
end
20-
21-
try
22-
oportfile = fopen('concore.oport');
23-
concore.oports = fscanf(oportfile,'%c');
24-
catch exc
25-
oportfile = '';
26-
end
27-
28-
concore.s = '';
29-
concore.olds = '';
30-
concore.delay = 1;
31-
concore.retrycount = 0;
32-
if exist('/in1','dir')==7 % 5/20/21 work for docker or local
33-
concore.inpath = '/in';
34-
concore.outpath = '/out';
35-
else
36-
concore.inpath = 'in';
37-
concore.outpath = 'out';
38-
end
39-
concore.simtime = 0;
40-
41-
concore_default_maxtime(100);
42-
end
1+
function import_concore
2+
global concore;
3+
4+
if ispc
5+
try
6+
pid = getpid();
7+
catch exc
8+
pid = feature('getpid');
9+
end
10+
outputpid = fopen('concorekill.bat','w');
11+
fprintf(outputpid,'%s',['taskkill /F /PID ',num2str(pid)]);
12+
fclose(outputpid);
13+
end
14+
15+
16+
try
17+
iportfile = fopen('concore.iport');
18+
concore.iports = fscanf(iportfile,'%c');
19+
catch exc
20+
iportfile = '';
21+
end
22+
23+
try
24+
oportfile = fopen('concore.oport');
25+
concore.oports = fscanf(oportfile,'%c');
26+
catch exc
27+
oportfile = '';
28+
end
29+
30+
concore.s = '';
31+
concore.olds = '';
32+
concore.delay = 1;
33+
concore.retrycount = 0;
34+
if exist('/in1','dir')==7 % 5/20/21 work for docker or local
35+
concore.inpath = '/in';
36+
concore.outpath = '/out';
37+
else
38+
concore.inpath = 'in';
39+
concore.outpath = 'out';
40+
end
41+
concore.simtime = 0;
42+
43+
concore_default_maxtime(100);
44+
end

import_concoredocker.m

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
1-
function import_concore
2-
global concore;
3-
4-
try
5-
pid = getpid();
6-
catch exc
7-
pid = feature('getpid');
8-
end
9-
outputpid = fopen('concorekill.bat','w');
10-
fprintf(outputpid,'%s',['taskkill /F /PID ',num2str(pid)]);
11-
fclose(outputpid);
12-
13-
14-
try
15-
iportfile = fopen('concore.iport');
16-
concore.iports = fscanf(iportfile,'%c');
17-
catch exc
18-
iportfile = '';
19-
end
20-
21-
try
22-
oportfile = fopen('concore.oport');
23-
concore.oports = fscanf(oportfile,'%c');
24-
catch exc
25-
oportfile = '';
26-
end
27-
28-
concore.s = '';
29-
concore.olds = '';
30-
concore.delay = 1;
31-
concore.retrycount = 0;
32-
if exist('/in1','dir')==7 % 5/20/21 work for docker or local
33-
concore.inpath = '/in';
34-
concore.outpath = '/out';
35-
else
36-
concore.inpath = 'in';
37-
concore.outpath = 'out';
38-
end
39-
concore.simtime = 0;
40-
41-
concore_default_maxtime(100);
42-
end
1+
function import_concore
2+
global concore;
3+
4+
% Docker/Linux environment — no Windows batch file generation
5+
6+
7+
try
8+
iportfile = fopen('concore.iport');
9+
concore.iports = fscanf(iportfile,'%c');
10+
catch exc
11+
iportfile = '';
12+
end
13+
14+
try
15+
oportfile = fopen('concore.oport');
16+
concore.oports = fscanf(oportfile,'%c');
17+
catch exc
18+
oportfile = '';
19+
end
20+
21+
concore.s = '';
22+
concore.olds = '';
23+
concore.delay = 1;
24+
concore.retrycount = 0;
25+
if exist('/in1','dir')==7 % 5/20/21 work for docker or local
26+
concore.inpath = '/in';
27+
concore.outpath = '/out';
28+
else
29+
concore.inpath = 'in';
30+
concore.outpath = 'out';
31+
end
32+
concore.simtime = 0;
33+
34+
concore_default_maxtime(100);
35+
end

0 commit comments

Comments
 (0)