File

File Commit Details

Date:2010-11-28 22:01:08 (7 years 11 months ago)
Author:Michael Baudin
Commit:7
Parents: 6
Message:Added unit tests.
Changes:
A/tests/unit_tests/touch.dia.ref
A/tests/unit_tests/touch.tst
A/demos/file_exists.sce
A/tests/unit_tests/nativename.dia.ref
A/tests/unit_tests
A/tests/unit_tests/nativename.tst
A/tests/unit_tests/split.dia.ref
A/tests/unit_tests/split.tst
A/tests/unit_tests/pathtype.dia.ref
A/tests/unit_tests/join.dia.ref
A/tests/unit_tests/normalize.dia.ref
A/tests/unit_tests/pathtype.tst
A/tests/unit_tests/join.tst
A/tests/unit_tests/normalize.tst
A/help/en_US/file_exists.xml
A/macros/file_exists.sci
A/tests/unit_tests/tempfile.dia.ref
A/tests/unit_tests/tempfile.tst
M/macros/file_split.sci
M/macros/file_pathtype.sci
M/macros/file_join.sci
M/macros/file_normalize.sci
M/demos/file.dem.gateway.sce
M/help/en_US/update_help.sce
M/demos/file_nativename.sce
M/demos/file_split.sce
M/readme.txt
M/demos/file_pathtype.sce
M/demos/file_join.sce
M/demos/file_normalize.sce
M/macros/file_nativename.sci

File differences

tests/unit_tests/nativename.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
tmpfile = file_tempfile ( );
path = file_nativename ( tmpfile );
//
name = file_nativename ( "\foo\myfile.txt" );
expected_Linux="/foo/myfile.txt";
expected_Windows="\foo\myfile.txt";
expected_Mac=":foo:myfile.txt";
if ( getos()=="Linux" ) then
assert_equal ( name , expected_Linux );
elseif ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Mac );
end
tests/unit_tests/tempfile.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
name1 = file_tempfile ( );
assert_equal ( file_exists(name1), %f );
name2 = file_tempfile ( );
assert_equal ( file_exists(name2), %f );
assert_equal ( name1<>name2 , %t );
name3 = file_tempfile ( );
assert_equal ( name2<>name3 , %t );
assert_equal ( file_exists(name3), %f );
//
tests/unit_tests/nativename.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
tmpfile = file_tempfile ( );
path = file_nativename ( tmpfile );
//
name = file_nativename ( "\foo\myfile.txt" );
expected_Linux="/foo/myfile.txt";
expected_Windows="\foo\myfile.txt";
expected_Mac=":foo:myfile.txt";
if ( getos()=="Linux" ) then
assert_equal ( name , expected_Linux );
elseif ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Mac );
end
tests/unit_tests/split.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
name = file_tempfile ( );
pathmat = file_split ( name );
assert_equal ( typeof(pathmat) , "string" );
assert_equal ( size(pathmat,"c") , 1 );
assert_equal ( size(pathmat,"r")>1 , %t );
//
pathmat = file_split ( "/foo/myfile.txt" );
expected = ["foo";"myfile.txt"];
assert_equal ( pathmat , expected );
tests/unit_tests/split.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
name = file_tempfile ( );
pathmat = file_split ( name );
assert_equal ( typeof(pathmat) , "string" );
assert_equal ( size(pathmat,"c") , 1 );
assert_equal ( size(pathmat,"r")>1 , %t );
//
pathmat = file_split ( "/foo/myfile.txt" );
expected = ["foo";"myfile.txt"];
assert_equal ( pathmat , expected );
tests/unit_tests/pathtype.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
name = file_tempfile ( );
file_touch ( name );
computed = file_pathtype ( name );
assert_equal ( computed , 1 );
//
computed = file_pathtype ( "foo.txt" );
assert_equal ( computed , 2 );
//
volumematrix = getdrives();
computed = file_pathtype ( volumematrix(1) );
if ( getos()=="Windows" ) then
assert_equal ( computed , 3 );
else
assert_equal ( computed , 1 );
end
tests/unit_tests/join.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
name = file_join ( ["foo" "myfile.txt" ] );
expected_Linux = "/foo/myfile.txt";
expected_Windows = "\foo\myfile.txt";
expected_Mac = ":foo:myfile.txt";
if ( getos()=="Linux" ) then
assert_equal ( name , expected_Linux );
elseif ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Mac );
end
tests/unit_tests/normalize.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
path = file_normalize("/foo/bla/myfile.txt");
expected = "/foo/bla/myfile.txt";
assert_equal ( path , expected );
//
path = file_normalize("\foo\bla\myfile.txt");
expected = "/foo/bla/myfile.txt";
assert_equal ( path , expected );
tests/unit_tests/pathtype.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
name = file_tempfile ( );
file_touch ( name );
computed = file_pathtype ( name );
assert_equal ( computed , 1 );
//
computed = file_pathtype ( "foo.txt" );
assert_equal ( computed , 2 );
//
volumematrix = getdrives();
computed = file_pathtype ( volumematrix(1) );
if ( getos()=="Windows" ) then
assert_equal ( computed , 3 );
else
assert_equal ( computed , 1 );
end
tests/unit_tests/join.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
name = file_join ( ["foo" "myfile.txt" ] );
expected_Linux = "/foo/myfile.txt";
expected_Windows = "\foo\myfile.txt";
expected_Mac = ":foo:myfile.txt";
if ( getos()=="Linux" ) then
assert_equal ( name , expected_Linux );
elseif ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Mac );
end
tests/unit_tests/normalize.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
path = file_normalize("/foo/bla/myfile.txt");
expected = "/foo/bla/myfile.txt";
assert_equal ( path , expected );
//
path = file_normalize("\foo\bla\myfile.txt");
expected = "/foo/bla/myfile.txt";
assert_equal ( path , expected );
tests/unit_tests/touch.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
name = file_tempfile ( );
file_touch ( name );
assert_equal ( file_exists(name), %t );
x = fileinfo ( name );
//
// Wait for 1 second
realtimeinit(1);//sets time unit to half a second
realtime(0);//sets current date to 0
realtime(1);
//
// Touch it again
file_touch ( name );
assert_equal ( file_exists(name), %t );
y = fileinfo ( name );
assert_equal ( y(6)>x(6) , %t );
tests/unit_tests/touch.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then pause,end
endfunction
name = file_tempfile ( );
file_touch ( name );
assert_equal ( file_exists(name), %t );
x = fileinfo ( name );
//
// Wait for 1 second
realtimeinit(1);//sets time unit to half a second
realtime(0);//sets current date to 0
realtime(1);
//
// Touch it again
file_touch ( name );
assert_equal ( file_exists(name), %t );
y = fileinfo ( name );
assert_equal ( y(6)>x(6) , %t );
tests/unit_tests/tempfile.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2008-2009 - INRIA - Michael Baudin
// Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
//
// assert_close --
// Returns 1 if the two real matrices computed and expected are close,
// i.e. if the relative distance between computed and expected is lesser than epsilon.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_close ( computed, expected, epsilon )
if expected==0.0 then
shift = norm(computed-expected);
else
shift = norm(computed-expected)/norm(expected);
end
if shift < epsilon then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
//
// assert_equal --
// Returns 1 if the two real matrices computed and expected are equal.
// Arguments
// computed, expected : the two matrices to compare
// epsilon : a small number
//
function flag = assert_equal ( computed , expected )
if ( and ( computed==expected ) ) then
flag = 1;
else
flag = 0;
end
if flag <> 1 then bugmes();quit;end
endfunction
name1 = file_tempfile ( );
assert_equal ( file_exists(name1), %f );
name2 = file_tempfile ( );
assert_equal ( file_exists(name2), %f );
assert_equal ( name1<>name2 , %t );
name3 = file_tempfile ( );
assert_equal ( name2<>name3 , %t );
assert_equal ( file_exists(name3), %f );
//
macros/file_nativename.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function path = file_nativename ( name )
// Returns the platform-specific name of a path.
//
// Calling Sequence
// path = file_nativename ( name )
//
// Parameters
// name : a 1-by-1 matrix of strings
// path : a 1-by-1 matrix of strings
//
// Description
// Returns the platform-specific name of a path.
//
// Examples
// tmpfile = file_tempfile ( )
// path = file_nativename ( tmpfile )
//
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
s = filesep()
path = strsubst(name,"\",s)
path = strsubst(path,"/",s)
endfunction
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function path = file_nativename ( name )
// Returns the platform-specific name of a path.
//
// Calling Sequence
// path = file_nativename ( name )
//
// Parameters
// name : a 1-by-1 matrix of strings
// path : a 1-by-1 matrix of strings
//
// Description
// Returns the platform-specific name of a path.
//
// Examples
// tmpfile = file_tempfile ( )
// path = file_nativename ( tmpfile )
// //
// name = file_nativename ( "\foo\myfile.txt" )
// expected_Linux="/foo/myfile.txt";
// expected_Windows="\foo\myfile.txt";
// expected_Mac=":foo:myfile.txt";
//
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
s = filesep()
path = strsubst(name,"\",s)
path = strsubst(path,"/",s)
endfunction
macros/file_split.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function pathmat = file_split ( name )
// Split the path into a matrix of strings.
//
// Calling Sequence
// pathmat = file_split ( name )
//
// Parameters
// name : a 1-by-1 matrix of strings
// pathmat : a n-by-1 matrix of strings
//
// Description
// Returns a matrix of string for each separator found in name.
//
// Examples
// name = file_tempfile ( )
// pathmat = file_split ( name )
//
// pathmat = file_split ( "/foo/myfile.txt" )
//
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
// We should use strsplit, but this does not work
//pathmat = strsplit(name,["\" "/" ":"],256)
sepmat(1) = filesep()
sepmat(2) = file_canonicalsep ( )
pathmat = []
buff = ""
for k = 1 : length(name)
c = part(name,k:k)
if ( or(c==sepmat) ) then
pathmat($+1) = buff
buff = ""
else
buff = buff + c
end
end
if ( buff <> "" ) then
pathmat($+1) = buff
end
pathmat(pathmat=="")=[]
endfunction
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function pathmat = file_split ( name )
// Split the path into a matrix of strings.
//
// Calling Sequence
// pathmat = file_split ( name )
//
// Parameters
// name : a 1-by-1 matrix of strings
// pathmat : a n-by-1 matrix of strings
//
// Description
// Returns a matrix of string for each separator found in name.
//
// Examples
// name = file_tempfile ( )
// pathmat = file_split ( name )
// //
// pathmat = file_split ( "/foo/myfile.txt" )
// expected = ["foo";"myfile.txt"]
//
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
// We should use strsplit, but this does not work
//pathmat = strsplit(name,["\" "/" ":"],256)
sepmat(1) = filesep()
sepmat(2) = file_canonicalsep ( )
pathmat = []
buff = ""
for k = 1 : length(name)
c = part(name,k:k)
if ( or(c==sepmat) ) then
pathmat($+1) = buff
buff = ""
else
buff = buff + c
end
end
if ( buff <> "" ) then
pathmat($+1) = buff
end
pathmat(pathmat=="")=[]
endfunction
macros/file_pathtype.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function t = file_pathtype ( name )
// Returns the type of a path.
//
// Calling Sequence
//
// Parameters
// name : a 1-by-1 matrix of strings
// t : a 1-by-1 matrix of floating point integers, t=1 for absolute, t=2 for relative, t=3 for volumerelative.
//
// Description
// Allows to get the type of a path.
//
// Examples
// tmpfile = file_tempfile ( )
// file_touch ( name )
// file_pathtype ( name ) // Should be 1
//
// file_pathtype ( "foo.txt" ) // Should be 2
//
// listofvolumes = getdrives()
// file_pathtype ( listofvolumes(1) ) // Should be 1
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
nativename = file_nativename ( name )
firstsep = file_firstsepindex ( name )
platform = getos ()
if ( firstsep==[]) then
t = 2
elseif (firstsep==1) then
// There is one separator, which is the first character
if ( platform == "Windows" ) then
t = 3
else
t = 1
end
else
firstcomp = part(nativename,1:firstsep-1)
if ( firstcomp=="." | firstcomp==".." ) then
t = 2
else
//
// The first item in the path is neither a ".", nor a ".."
// and the first character is not a separator.
// On Linux and Mac, this is a relative file.
// But on Windows, "toto/titi.txt" is relative and
// "C:/titi.txt" is absolute : we have to make the difference
// between "toto", which is just a regular directory name,
// and "C:", which is a file volume.
//
listofvolumes = getdrives()
firstcomp = firstcomp + "/"
listofvolumes = strsubst(listofvolumes,"\","/")
volumeindex = find(listofvolumes==firstcomp)
if ( volumeindex <> [] ) then
t = 1
else
t = 2
end
end
end
endfunction
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function t = file_pathtype ( name )
// Returns the type of a path.
//
// Calling Sequence
//
// Parameters
// name : a 1-by-1 matrix of strings
// t : a 1-by-1 matrix of floating point integers, t=1 for absolute, t=2 for relative, t=3 for volumerelative.
//
// Description
// Allows to get the type of a path.
// If name refers to a specific file on a specific volume, the path
// type will be absolute.
// If name refers to a file relative to the current
// working directory, then the path type will be relative.
// If name refers to a file relative to the current working directory on a specified volume, or to
// a specific file on the current working volume, then the path type is volumerelative.
//
// Volume relative can happen only on Windows.
//
// For example:
// <itemizedlist>
// <listitem>"." is relative on all platforms</listitem>
// <listitem>".." is relative on all platforms</listitem>
// <listitem>"/" is absolute on Linux/Unix</listitem>
// <listitem>"C:/" is absolute on Windows (if the C:/ exists)</listitem>
// <listitem>"/" is volumerelative on windows and refers to the current volume (for example C:/)</listitem>
// <listitem>"toto.txt" is relative on all platforms</listitem>
// <listitem>"./toto.txt" is relative on all platforms </listitem>
// </itemizedlist>
//
// Examples
// name = file_tempfile ( )
// file_touch ( name )
// file_pathtype ( name ) // Should be 1
// //
// file_pathtype ( "foo.txt" ) // Should be 2
// //
// volumematrix = getdrives()
// file_pathtype ( volumematrix(1) ) // Should be 3 on Windows, 1 on Linux
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
nativename = file_nativename ( name )
firstsep = file_firstsepindex ( name )
platform = getos ()
if ( firstsep==[]) then
t = 2
elseif (firstsep==1) then
// There is one separator, which is the first character
if ( platform == "Windows" ) then
t = 3
else
t = 1
end
else
firstcomp = part(nativename,1:firstsep-1)
if ( firstcomp=="." | firstcomp==".." ) then
t = 2
else
//
// The first item in the path is neither a ".", nor a ".."
// and the first character is not a separator.
// On Linux and Mac, this is a relative file.
// But on Windows, "toto/titi.txt" is relative and
// "C:/titi.txt" is absolute : we have to make the difference
// between "toto", which is just a regular directory name,
// and "C:", which is a file volume.
//
volumematrix = getdrives()
firstcomp = firstcomp + "/"
volumematrix = strsubst(volumematrix,"\","/")
volumeindex = find(volumematrix==firstcomp)
if ( volumeindex <> [] ) then
t = 1
else
t = 2
end
end
end
endfunction
macros/file_exists.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function ex = file_exists ( name )
// Returns %t if the file exists
//
// Calling Sequence
// ex = file_exists ( name )
//
// Parameters
// ex : a 1-by-1 matrix of booleans, ex is %t if the file exists, ex is %f if not
//
// Description
// Returns %t if the file exists.
//
// Examples
// name = file_tempfile ( )
// file_touch ( name )
// ex = file_exists ( name ) // %t
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
ex = (fileinfo(name)<>[])
endfunction
macros/file_join.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function name = file_join ( pathmat )
// Join sub-paths from a matrix of strings.
//
// Calling Sequence
// name = file_join ( pathmat )
//
// Parameters
// pathmat : a n-by-1 matrix of strings
// name : a 1-by-1 matrix of strings
//
// Description
// Returns a path made by joining the paths, using the
// platform-specific canonical separator, that is
// "/" on Windows and Linux and ":" on Mac.
//
// Examples
// name = file_join ( ["foo" "myfile.txt" ] )
//
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
separator = file_canonicalsep ( )
name = ""
for k = 1 : size(pathmat,"*")
name = name + separator + pathmat(k)
end
endfunction
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function name = file_join ( pathmat )
// Join sub-paths from a matrix of strings.
//
// Calling Sequence
// name = file_join ( pathmat )
//
// Parameters
// pathmat : a n-by-1 matrix of strings
// name : a 1-by-1 matrix of strings
//
// Description
// Returns a path made by joining the paths, using the
// platform-specific canonical separator, that is
// "/" on Windows and Linux and ":" on Mac.
//
// Examples
// name = file_join ( ["foo" "myfile.txt" ] )
// expected_Linux = "/foo/myfile.txt"
// expected_Windows = "\foo\myfile.txt"
// expected_Mac = ":foo:myfile.txt"
//
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
separator = file_canonicalsep ( )
name = ""
for k = 1 : size(pathmat,"*")
name = name + separator + pathmat(k)
end
endfunction
macros/file_normalize.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function path = file_normalize ( name )
// Returns a unique normalized path.
//
// Calling Sequence
// name : a 1-by-1 matrix of strings
// path : a 1-by-1 matrix of strings
//
// Description
// Returns a unique normalized path representation for the
// file-system object (file, directory, link, etc), whose string
// value can be used as a unique identifier for it.
//
// TODO : manage "."
// TODO : manage ".."
// TODO : manage relative files
//
// Examples
// file_normalize ( "/foo/myfile.txt" )
// file_normalize ( "\foo\myfile.txt" )
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
path = strsubst(name,"\","/")
endfunction
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function path = file_normalize ( name )
// Returns a unique normalized path.
//
// Calling Sequence
// name : a 1-by-1 matrix of strings
// path : a 1-by-1 matrix of strings
//
// Description
// Returns a unique normalized path representation for the
// file-system object (file, directory, link, etc), whose string
// value can be used as a unique identifier for it.
//
// TODO : manage "."
// TODO : manage ".."
// TODO : manage relative files
//
// Examples
// file_normalize ( "/foo/myfile.txt" )
// expected = "/foo/bla/myfile.txt";
// //
// file_normalize ( "\foo\myfile.txt" )
// expected = "/foo/bla/myfile.txt";
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
path = strsubst(name,"\","/")
endfunction
demos/file_nativename.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// This help file was automatically generated from file_nativename.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_nativename.sci
//
tmpfile = file_tempfile ( )
path = file_nativename ( tmpfile )
halt() // Press return to continue
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_nativename.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
//
// This help file was automatically generated from file_nativename.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_nativename.sci
//
tmpfile = file_tempfile ( )
path = file_nativename ( tmpfile )
//
name = file_nativename ( "\foo\myfile.txt" )
expected_Linux="/foo/myfile.txt";
expected_Windows="\foo\myfile.txt";
expected_Mac=":foo:myfile.txt";
halt() // Press return to continue
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_nativename.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_split.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// This help file was automatically generated from file_split.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_split.sci
//
name = file_tempfile ( )
pathmat = file_split ( name )
halt() // Press return to continue
pathmat = file_split ( "/foo/myfile.txt" )
halt() // Press return to continue
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_split.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
//
// This help file was automatically generated from file_split.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_split.sci
//
name = file_tempfile ( )
pathmat = file_split ( name )
//
pathmat = file_split ( "/foo/myfile.txt" )
expected = ["foo";"myfile.txt"]
halt() // Press return to continue
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_split.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_pathtype.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
// This help file was automatically generated from file_pathtype.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_pathtype.sci
//
tmpfile = file_tempfile ( )
file_touch ( name )
file_pathtype ( name ) // Should be 1
halt() // Press return to continue
file_pathtype ( "foo.txt" ) // Should be 2
halt() // Press return to continue
listofvolumes = getdrives()
file_pathtype ( listofvolumes(1) ) // Should be 1
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_pathtype.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
//
// This help file was automatically generated from file_pathtype.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_pathtype.sci
//
name = file_tempfile ( )
file_touch ( name )
file_pathtype ( name ) // Should be 1
//
file_pathtype ( "foo.txt" ) // Should be 2
//
volumematrix = getdrives()
file_pathtype ( volumematrix(1) ) // Should be 3 on Windows, 1 on Linux
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_pathtype.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_exists.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// This help file was automatically generated from file_exists.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_exists.sci
//
name = file_tempfile ( )
file_touch ( name )
ex = file_exists ( name ) // %t
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_exists.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_join.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
// This help file was automatically generated from file_join.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_join.sci
//
name = file_join ( ["foo" "myfile.txt" ] )
halt() // Press return to continue
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_join.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
//
// This help file was automatically generated from file_join.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_join.sci
//
name = file_join ( ["foo" "myfile.txt" ] )
expected_Linux = "/foo/myfile.txt"
expected_Windows = "\foo\myfile.txt"
expected_Mac = ":foo:myfile.txt"
halt() // Press return to continue
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_join.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_normalize.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
// This help file was automatically generated from file_normalize.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_normalize.sci
//
file_normalize ( "/foo/myfile.txt" )
file_normalize ( "\foo\myfile.txt" )
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_normalize.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
//
// This help file was automatically generated from file_normalize.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_normalize.sci
//
file_normalize ( "/foo/myfile.txt" )
expected = "/foo/bla/myfile.txt";
//
file_normalize ( "\foo\myfile.txt" )
expected = "/foo/bla/myfile.txt";
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_normalize.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file.dem.gateway.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// This help file was automatically generated using helpupdate
// PLEASE DO NOT EDIT
demopath = get_absolute_file_path("file.dem.gateway.sce");
subdemolist = [
"file_touch", "file_touch.sce"; ..
"file_tempfile", "file_tempfile.sce"; ..
"file_split", "file_split.sce"; ..
"file_pathtype", "file_pathtype.sce"; ..
"file_normalize", "file_normalize.sce"; ..
"file_nativename", "file_nativename.sce"; ..
"file_join", "file_join.sce"; ..
];
subdemolist(:,2) = demopath + subdemolist(:,2)
// This help file was automatically generated using helpupdate
// PLEASE DO NOT EDIT
demopath = get_absolute_file_path("file.dem.gateway.sce");
subdemolist = [
"file_touch", "file_touch.sce"; ..
"file_join", "file_join.sce"; ..
"file_pathtype", "file_pathtype.sce"; ..
"file_normalize", "file_normalize.sce"; ..
"file_split", "file_split.sce"; ..
"file_tempfile", "file_tempfile.sce"; ..
"file", "file.sce"; ..
"file_exists", "file_exists.sce"; ..
"file_nativename", "file_nativename.sce"; ..
];
subdemolist(:,2) = demopath + subdemolist(:,2)
help/en_US/update_help.sce
224224
225225
226226
227
227228
228229
229230
mprintf("Updating floatingpoint\n");
helpdir = fullfile(cwd);
funmat = [
"file_exists"
"file_nativename"
"file_normalize"
"file_split"
help/en_US/file_exists.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_exists.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_exists" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ns3="http://www.w3.org/1999/xhtml"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:db="http://docbook.org/ns/docbook">
<refnamediv>
<refname>file_exists</refname><refpurpose>Returns %t if the file exists</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
ex = file_exists ( name )
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry><term>ex :</term>
<listitem><para> a 1-by-1 matrix of booleans, ex is %t if the file exists, ex is %f if not</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Returns %t if the file exists.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
name = file_tempfile ( )
file_touch ( name )
ex = file_exists ( name ) // %t
]]></programlisting>
</refsection>
<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Copyright (C) 2010 - DIGITEO - Michael Baudin</member>
<member>Copyright (c) 2008 - Michael Baudin</member>
<member>Copyright (c) 2008 - Arjen Markus</member>
</simplelist>
</refsection>
</refentry>
readme.txt
4141
4242
4343
44
4445
4546
4647
* http://www.tcl.tk/man/tcl8.4/TclCmd/file.htm
* http://flibs.cvs.sourceforge.net/viewvc/flibs/src/filedir/m_vfile.f90?view=markup
* http://flibs.cvs.sourceforge.net/viewvc/flibs/tests/filedir/test_m_filedir.f90?view=markup
TODO
----

Archive Download the corresponding diff file

Revision: 7