File

File Commit Details

Date:2010-12-05 22:10:38 (7 years 11 months ago)
Author:Michael Baudin
Commit:14
Parents: 13
Message: * Update the unit tests of join, split for Linux. * Add unit test for isfile, isdirectory. * Improved normalize, join, split
Changes:
A/tests/unit_tests/isfile.tst
A/demos/file_isfile.sce
A/help/en_US/file_isdirectory.xml
A/macros/file_isdirectory.sci
A/help/en_US/file_isfile.xml
A/macros/file_isfile.sci
A/tests/unit_tests/isdirectory.tst
A/demos/file_isdirectory.sce
A/demos/file_separator.sce
M/help/en_US/file_split.xml
M/macros/file_split.sci
M/help/en_US/file_join.xml
M/help/en_US/file_normalize.xml
M/macros/file_join.sci
M/macros/file_normalize.sci
M/demos/file.dem.gateway.sce
M/help/en_US/update_help.sce
M/changelog.txt
M/tests/unit_tests/split.tst
M/tests/unit_tests/pathtype.dia.ref
M/demos/file_split.sce
M/tests/unit_tests/join.tst
M/readme.txt
M/tests/unit_tests/normalize.tst
M/demos/file_join.sce
M/demos/file_normalize.sce

File differences

tests/unit_tests/isfile.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
// 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_join([SCI,"etc","scilab.start"]);
tf = file_isfile ( path );
assert_equal ( tf , %t );
//
tf = file_isfile ( TMPDIR );
assert_equal ( tf , %f );
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
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
// 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 );
//
pathmat = file_split ( "C:\foo\myfile.txt" );
if ( getos()=="Windows" ) then
assert_equal ( pathmat , ["C:\";"foo";"myfile.txt"] );
else
// TODO
end
//
pathmat = file_split ( "C:/foo/myfile.txt" );
if ( getos()=="Windows" ) then
assert_equal ( pathmat , ["C:/";"foo";"myfile.txt"] );
else
// TODO
end
// 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 );
//
pathmat = file_split ( "C:\foo\myfile.txt" );
if ( getos()=="Windows" ) then
assert_equal ( pathmat , ["C:\";"foo";"myfile.txt"] );
else
assert_equal ( pathmat , "C:\foo\myfile.txt" );
end
//
pathmat = file_split ( "C:/foo/myfile.txt" );
if ( getos()=="Windows" ) then
assert_equal ( pathmat , ["C:/";"foo";"myfile.txt"] );
else
assert_equal ( pathmat , ["C:";"foo";"myfile.txt"] );
end
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
62
63
64
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
// 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) );
assert_equal ( computed , 1 );
//
computed = file_pathtype ( "/" );
if ( getos()=="Windows" ) then
assert_equal ( computed , 3 );
else
assert_equal ( computed , 1 );
end
// 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) );
assert_equal ( computed , 1 );
//
computed = file_pathtype ( "/" );
if ( getos()=="Windows" ) then
assert_equal ( computed , 3 );
else
assert_equal ( computed , 1 );
end
//
computed = file_pathtype ( "." );
assert_equal ( computed , 2 );
//
computed = file_pathtype ( ".." );
assert_equal ( computed , 2 );
//
computed = file_pathtype ( "./foo.txt" );
assert_equal ( computed , 2 );
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
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
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) 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_WinLinux = "foo/myfile.txt";
expected_Mac = "foo:myfile.txt";
if ( or(getos()==["Linux" "Windows"]) ) then
assert_equal ( name , expected_WinLinux );
else
assert_equal ( name , expected_Mac );
end
//
name = file_join ( ["C:\" "foo" "myfile.txt" ] );
expected_Windows = "C:/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
// TODO
end
//
name = file_join ( ["C:/" "foo" "myfile.txt" ] );
expected_Windows = "C:/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
// TODO
end
//
name = file_join ( ["/" "foo" "myfile.txt" ] );
expected_Windows = "/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
// TODO
end
//
name = file_join ( ["\" "foo" "myfile.txt" ] );
expected_Windows = "/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
// TODO
end
// 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_WinLinux = "foo/myfile.txt";
expected_Mac = "foo:myfile.txt";
if ( or(getos()==["Linux" "Windows"]) ) then
assert_equal ( name , expected_WinLinux );
else
assert_equal ( name , expected_Mac );
end
//
name = file_join ( ["C:\" "foo" "myfile.txt" ] );
expected_Windows = "C:/foo/myfile.txt";
expected_Linux = "C:\/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Linux );
end
//
name = file_join ( ["C:/" "foo" "myfile.txt" ] );
expected_Windows = "C:/foo/myfile.txt";
expected_Linux = "C:/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Linux );
end
//
name = file_join ( ["/" "foo" "myfile.txt" ] );
expected_Windows = "/foo/myfile.txt";
expected_Linux = "/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Linux );
end
//
name = file_join ( ["\" "foo" "myfile.txt" ] );
expected_Windows = "/foo/myfile.txt";
expected_Linux = "\/foo/myfile.txt";
if ( getos()=="Windows" ) then
assert_equal ( name , expected_Windows );
else
assert_equal ( name , expected_Linux );
end
tests/unit_tests/normalize.tst
5353
5454
5555
56
57
56
57
58
59
60
61
62
63
64
5865
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
5993
60
expected = "/foo/bla/myfile.txt";
assert_equal ( path , expected );
//
path = file_normalize("\foo\bla\myfile.txt");
expected = "/foo/bla/myfile.txt";
if ( getos()=="Windows") then
path = file_normalize("\foo\bla\myfile.txt");
expected = "/foo/bla/myfile.txt";
assert_equal ( path , expected );
end
//
// Check "."
path = file_normalize(".");
expected = pwd();
assert_equal ( path , expected );
//
// Check ".."
path = file_normalize("..");
cwd = pwd();
k = file_lastsepindex(cwd);
expected = part(cwd,1:k-1);
assert_equal ( path , expected );
//
// Check ".."
path = file_normalize("/foo1/foo2/../myfile.txt");
expected = "/foo1/myfile.txt";
assert_equal ( path , expected );
//
// Check "."
path = file_normalize("/foo1/foo2/./myfile.txt");
expected = "/foo1/foo2/myfile.txt";
assert_equal ( path , expected );
//
// Check "."
path = file_normalize("./myfile.txt");
expected = pwd()+"/myfile.txt";
assert_equal ( path , expected );
//
// Check "." and ".."
path = file_normalize("./foo/../myfile.txt");
expected = pwd()+"/myfile.txt";
assert_equal ( path , expected );
tests/unit_tests/isdirectory.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
// 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_join([SCI,"etc","scilab.start"]);
tf = file_isdirectory ( path );
assert_equal ( tf , %f );
//
tf = file_isdirectory ( TMPDIR );
assert_equal ( tf , %t );
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
// 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 matrox of strings whose elements are the path components in name.
// The first element of the list will have the same path type as name.
// All other elements will be relative.
//
// Examples
// name = file_tempfile ( )
// pathmat = file_split ( name )
// //
// pathmat = file_split ( "/foo/myfile.txt" )
// expected = ["/";"foo";"myfile.txt"]
// //
// pathmat = file_split ( "C:\foo\myfile.txt" )
// expected_Windows = ["C:\";"foo";"myfile.txt"]
// //
// pathmat = file_split ( "C:/foo/myfile.txt" )
// expected_Windows = ["C:/";"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) = file_separator()
sepmat(2) = file_canonicalsep ( )
pathmat = []
buff = ""
firstcomp = %t
for k = 1 : length(name)
c = part(name,k:k)
if ( or(c==sepmat) ) then
if ( firstcomp ) then
pathmat($+1) = buff+c
firstcomp = %f
else
pathmat($+1) = buff
end
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 matrox of strings whose elements are the path components in name.
// The first element of the list will have the same path type as name.
// All other elements will be relative.
//
// Examples
// name = file_tempfile ( )
// pathmat = file_split ( name )
// //
// pathmat = file_split ( "/foo/myfile.txt" )
// expected = ["/";"foo";"myfile.txt"]
// //
// pathmat = file_split ( "C:\foo\myfile.txt" )
// expected_Windows = ["C:\";"foo";"myfile.txt"]
// expected_Linux = "C:\foo\myfile.txt"
// //
// pathmat = file_split ( "C:/foo/myfile.txt" )
// expected_Windows = ["C:/";"foo";"myfile.txt"]
// expected_Linux = ["C:";"foo";"myfile.txt"]
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
sepmat(1) = file_separator()
sepmat(2) = file_canonicalsep ( )
pathmat = []
buff = ""
firstcomp = %t
for k = 1 : length(name)
c = part(name,k:k)
if ( or(c==sepmat) ) then
if ( firstcomp & buff == "" ) then
pathmat($+1) = c
firstcomp = %f
else
pathmat($+1) = buff
end
buff = ""
else
buff = buff + c
end
end
if ( buff <> "" ) then
pathmat($+1) = buff
end
pathmat(pathmat=="")=[]
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
42
43
44
45
46
47
48
49
50
51
52
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
// 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_WinLinux = "foo/myfile.txt"
// expected_Mac = "foo:myfile.txt"
//
// name = file_join ( ["C:\" "foo" "myfile.txt" ] )
// expected_Windows = "C:\foo\myfile.txt"
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
separator = file_canonicalsep ( )
//
// Replace the potential existing separators by an empty string.
// The separator will be added later, in the loop.
name = pathmat(1)
name = strsubst(name,"\","")
name = strsubst(name,"/","")
//
// Join the remaining parts
for k = 2 : 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_WinLinux = "foo/myfile.txt"
// expected_Mac = "foo:myfile.txt"
//
// name = file_join ( ["C:\" "foo" "myfile.txt" ] )
// expected_Windows = "C:\foo\myfile.txt"
// expected_Linux = "C:\/foo/myfile.txt"
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
separator = file_canonicalsep ()
//
// 1. Add the directory name
//
name = pathmat(1)
//
// Join the remaining parts
for k = 2 : size(pathmat,"*")
//
// If the file type is absolute, remove the directory
//
pathtype = file_pathtype ( pathmat(k) )
if ( pathtype == 1 | pathtype == 3) then
name = pathmat(k)
else
//
// If the last character of the directory name is allready
// a separator, do not insert a separator.
// Otherwise, insert one.
//
lastsep = file_lastsepindex ( name )
dirname_length = length ( name )
if ( lastsep <> dirname_length ) then
name = name + separator
end
name = name + pathmat(k)
end
end
endfunction
macros/file_isdirectory.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
// 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 tf = file_isdirectory ( name )
// Returns %t if the path is a directory.
//
// Calling Sequence
// name : a 1-by-1 matrix of strings
// tf : a 1-by-1 matrix of booleans
//
// Description
// Returns %t if the name is a directory, %f if not.
//
// Examples
// file_isdirectory ( file_join([SCI,"etc","scilab.start"]) ) // %f
// file_isdirectory ( TMPDIR ) // %t
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
tf = isdir(name)
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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// 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.
// A normalized path
// is an absolute path which has all '../', './' removed. Also it is one which
// is in the ``standard'' format for the native platform.
// On Windows or Mac, any platform-specific separator in the path
// is replaced by the platform-independent separator "/".
// On Windows it also means we want the long form with that form's
// case-dependence (which gives us a unique, case-dependent path).
//
// 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
if ( %t ) then
path = strsubst(name,"\","/")
return
end
//
// Compute an absolute path name : absolutename
pathtype = file_pathtype ( name )
if ( pathtype == 1 ) then
absolutename = name
elseif ( pathtype == 3 ) then
//
// Replace the leading / by the current volume name
//
cwd = pwd ()
firstsep = file_firstsepindex ( cwd )
filevolume = part ( cwd , 1:firstsep - 1 )
// Remove the leading / in the filename
filelength = length ( name )
if ( filelength > 1 ) then
fileend = part ( name , 2 : filelength )
absolutename = file_join ( filevolume , fileend )
else
absolutename = filevolume
end
else
//
// Add the current directory to the relative path
//
directory = pwd ()
absolutename = file_join ( directory , name )
end
//
// 2. Splitting the absolutename into pieces
//
listOfFiles = file_split ( absolutename )
nbitems = length ( listOfFiles )
//
// 3. Tag the components in the path which must be kept
//
// By default all items must be kept in the path
allocate ( keepitem (1:nbitems) )
keepitem = %t
// skipnb is the current number of items to skip
skipnb = 0
//
// 3.1 Process a loop from the end of the path to the begining
//
for itemindex = nbitems : -1 : 1
item = listOfFiles ( itemindex )
if ( item == ".." ) then
// If the item is a "..", then remember that there is a path to skip and skip the ".." itself
skipnb = skipnb + 1
keepitem ( itemindex ) = %f
elseif ( item == "." ) then
keepitem ( itemindex ) = %f
elseif ( skipnb > 0 ) then
// If the current item is a regular path, but there is an item to skip
// (because of a previous ".."), skip it
skipnb = skipnb - 1
keepitem ( itemindex ) = %f
end
end
//
// 4. Now compute the normalized path by keeping only the required
// path components and insert separator between components, if necessary
//
vfile_normalize = ""
separator = file_canonicalseparator ( )
pathindex = 0
for itemindex = 1 : nbitems
if ( keepitem ( itemindex ) ) then
pathindex = pathindex + 1
item = listOfFiles ( itemindex )
if ( pathindex > 1 ) then
vfile_normalize = vfile_normalize + separator
end
vfile_normalize = vfile_normalize + item
end
end
//
// 5. If the given file is a directory, the name must end with a "/"
//
isdirectory = vfile_isdirectory ( vfile_normalize )
if ( isdirectory ) then
separator = file_canonicalsep ()
vfile_normalize = vfile_normalize + separator
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 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.
// A normalized path
// is an absolute path which has all '../', './' removed. Also it is one which
// is in the ``standard'' format for the native platform.
// On Windows or Mac, any platform-specific separator in the path
// is replaced by the platform-independent separator "/".
// On Windows it also means we want the long form with that form's
// case-dependence (which gives us a unique, case-dependent path).
//
// Examples
// file_normalize ( "/foo/myfile.txt" )
// expected = "/foo/bla/myfile.txt";
// //
// file_normalize ( "\foo\myfile.txt" )
// expected = "/foo/bla/myfile.txt";
// //
// file_normalize ( "." )
// expected = pwd()
// //
// file_normalize ( ".." )
// //
// file_normalize ( "../file.txt" )
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
// Copyright (c) 2008 - Michael Baudin
// Copyright (c) 2008 - Arjen Markus
//
// Compute an absolute path name : absolutename
pathtype = file_pathtype ( name )
if ( pathtype == 1 ) then
absolutename = name
elseif ( pathtype == 3 ) then
//
// Replace the leading / by the current volume name
//
cwd = pwd ()
firstsep = file_firstsepindex ( cwd )
filevolume = part ( cwd , 1:firstsep - 1 )
// Remove the leading / in the filename
filelength = length ( name )
if ( filelength > 1 ) then
fileend = part ( name , 2 : filelength )
absolutename = file_join ( filevolume , fileend )
else
absolutename = filevolume
end
else
//
// Add the current directory to the relative path
//
directory = pwd ()
absolutename = file_join ( [directory , name] )
end
//
// 2. Splitting the absolutename into pieces
//
listOfFiles = file_split ( absolutename )
nbitems = size ( listOfFiles , "*" )
//
// 3. Tag the components in the path which must be kept
//
// By default all items must be kept in the path
keepitem(1:nbitems) = %t
// skipnb is the current number of items to skip
skipnb = 0
//
// 3.1 Process a loop from the end of the path to the begining
// Compute keepitem(i): %t if i is to keep, %f if to remove
//
for i = nbitems : -1 : 1
item = listOfFiles ( i )
if ( item == ".." ) then
// If the item is a "..", then remember that there is a path to skip and skip the ".." itself
skipnb = skipnb + 1
keepitem ( i ) = %f
elseif ( item == "." ) then
keepitem ( i ) = %f
elseif ( skipnb > 0 ) then
// If the current item is a regular path, but there is an item to skip
// (because of a previous ".."), skip it
skipnb = skipnb - 1
keepitem ( i ) = %f
end
end
//
// 4. Now compute the normalized path by keeping only the required
// path components and insert separator between components, if necessary
//
path = ""
separator = file_canonicalsep ( )
pathindex = 0
for i = 1 : nbitems
if ( keepitem ( i ) ) then
pathindex = pathindex + 1
item = listOfFiles ( i )
if ( pathindex > 1 & path <> separator ) then
path = path + separator
end
path = path + item
end
end
//
// 5. If the given file is a directory, the name must end with a "/"
//
if ( %f ) then
// Surely, not on Linux. On Windows ?
isdirectory = file_isdirectory ( path )
if ( isdirectory ) then
separator = file_canonicalsep ()
path = path + separator
end
end
endfunction
macros/file_isfile.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
// 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 tf = file_isfile ( name )
// Returns %t if the path is a file.
//
// Calling Sequence
// name : a 1-by-1 matrix of strings
// tf : a 1-by-1 matrix of booleans
//
// Description
// Returns %t if the name is a file, %f if not.
//
// Examples
// file_isfile ( filejoin([SCI,"etc","scilab.start"] ) // %t
// file_isfile ( TMPDIR ) // %f
//
// Authors
// Copyright (C) 2010 - DIGITEO - Michael Baudin
tf = isfile(name)
endfunction
changelog.txt
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
9
10
changelog of the File Toolbox
file (not released yet)
* Initial version
* Add file_atime (from Scilab/fileinfo)
* Add file_separator (from Scilab/pathsep)
changelog of the File Toolbox
file (not released yet)
* Initial version
* Add file_atime (from Scilab/fileinfo)
* Add file_separator (from Scilab/pathsep)
* Update the unit tests of join, split for Linux.
* Add unit test for isfile, isdirectory.
* Improved normalize, join, split
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
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
26
//
// 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_WinLinux = "foo/myfile.txt"
expected_Mac = "foo:myfile.txt"
halt() // Press return to continue
name = file_join ( ["C:\" "foo" "myfile.txt" ] )
expected_Windows = "C:\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_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_WinLinux = "foo/myfile.txt"
expected_Mac = "foo:myfile.txt"
halt() // Press return to continue
name = file_join ( ["C:\" "foo" "myfile.txt" ] )
expected_Windows = "C:\foo\myfile.txt"
expected_Linux = "C:\/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_join.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_isdirectory.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
// This help file was automatically generated from file_isdirectory.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_isdirectory.sci
//
file_isdirectory ( file_join([SCI,"etc","scilab.start"]) ) // %f
file_isdirectory ( TMPDIR ) // %t
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_isdirectory.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
demos/file_normalize.sce
1212
1313
1414
15
16
17
18
19
20
21
1522
1623
1724
//
file_normalize ( "\foo\myfile.txt" )
expected = "/foo/bla/myfile.txt";
//
file_normalize ( "." )
expected = pwd()
//
file_normalize ( ".." )
//
file_normalize ( "../file.txt" )
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
demos/file_separator.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//
// This help file was automatically generated from file_separator.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_separator.sci
//
file_separator()
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_separator.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
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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_separator", "file_separator.sce"; ..
"file_pathtype", "file_pathtype.sce"; ..
"file_normalize", "file_normalize.sce"; ..
"file_nativename", "file_nativename.sce"; ..
"file_join", "file_join.sce"; ..
"file_exists", "file_exists.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_isdirectory", "file_isdirectory.sce"; ..
"file_tempfile", "file_tempfile.sce"; ..
"file_separator", "file_separator.sce"; ..
"file", "file.sce"; ..
"file_isfile", "file_isfile.sce"; ..
"file_exists", "file_exists.sce"; ..
"file_nativename", "file_nativename.sce"; ..
];
subdemolist(:,2) = demopath + subdemolist(:,2)
demos/file_isfile.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
// This help file was automatically generated from file_isfile.sci using help_from_sci().
// PLEASE DO NOT EDIT
//
mode(1)
//
// Demo of file_isfile.sci
//
file_isfile ( filejoin([SCI,"etc","scilab.start"] ) // %t
file_isfile ( TMPDIR ) // %f
halt() // Press return to continue
//========= E N D === O F === D E M O =========//
//
// Load this script into the editor
//
filename = "file_isfile.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
26
27
28
29
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
//
// 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"]
//
pathmat = file_split ( "C:\foo\myfile.txt" )
expected_Windows = ["C:\";"foo";"myfile.txt"]
//
pathmat = file_split ( "C:/foo/myfile.txt" )
expected_Windows = ["C:/";"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_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"]
//
pathmat = file_split ( "C:\foo\myfile.txt" )
expected_Windows = ["C:\";"foo";"myfile.txt"]
expected_Linux = "C:\foo\myfile.txt"
//
pathmat = file_split ( "C:/foo/myfile.txt" )
expected_Windows = ["C:/";"foo";"myfile.txt"]
expected_Linux = ["C:";"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_split.sce";
dname = get_absolute_file_path(filename);
editor ( fullfile(dname,filename) );
help/en_US/file_join.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
68
69
70
71
72
73
74
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_join.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_join" 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_join</refname><refpurpose>Join sub-paths from a matrix of strings.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
name = file_join ( pathmat )
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry><term>pathmat :</term>
<listitem><para> a n-by-1 matrix of strings</para></listitem></varlistentry>
<varlistentry><term>name :</term>
<listitem><para> a 1-by-1 matrix of strings</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Returns a path made by joining the paths, using the
platform-specific canonical separator, that is
"/" on Windows and Linux and ":" on Mac.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
name = file_join ( ["foo" "myfile.txt" ] )
expected_WinLinux = "foo/myfile.txt"
expected_Mac = "foo:myfile.txt"
name = file_join ( ["C:\" "foo" "myfile.txt" ] )
expected_Windows = "C:\foo\myfile.txt"
]]></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>
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_join.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_join" 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_join</refname><refpurpose>Join sub-paths from a matrix of strings.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
name = file_join ( pathmat )
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry><term>pathmat :</term>
<listitem><para> a n-by-1 matrix of strings</para></listitem></varlistentry>
<varlistentry><term>name :</term>
<listitem><para> a 1-by-1 matrix of strings</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Returns a path made by joining the paths, using the
platform-specific canonical separator, that is
"/" on Windows and Linux and ":" on Mac.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
name = file_join ( ["foo" "myfile.txt" ] )
expected_WinLinux = "foo/myfile.txt"
expected_Mac = "foo:myfile.txt"
name = file_join ( ["C:\" "foo" "myfile.txt" ] )
expected_Windows = "C:\foo\myfile.txt"
expected_Linux = "C:\/foo/myfile.txt"
]]></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>
help/en_US/file_isdirectory.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_isdirectory.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_isdirectory" 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_isdirectory</refname><refpurpose>Returns %t if the path is a directory.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
name : a 1-by-1 matrix of strings
tf : a 1-by-1 matrix of booleans
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>
Returns %t if the name is a directory, %f if not.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
file_isdirectory ( file_join([SCI,"etc","scilab.start"]) ) // %f
file_isdirectory ( TMPDIR ) // %t
]]></programlisting>
</refsection>
<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Copyright (C) 2010 - DIGITEO - Michael Baudin</member>
</simplelist>
</refsection>
</refentry>
help/en_US/file_normalize.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
68
69
70
71
72
73
74
75
76
77
78
79
80
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_normalize.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_normalize" 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_normalize</refname><refpurpose>Returns a unique normalized path.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
name : a 1-by-1 matrix of strings
path : a 1-by-1 matrix of strings
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>
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.
A normalized path
is an absolute path which has all '../', './' removed. Also it is one which
is in the ``standard'' format for the native platform.
On Windows or Mac, any platform-specific separator in the path
is replaced by the platform-independent separator "/".
On Windows it also means we want the long form with that form's
case-dependence (which gives us a unique, case-dependent path).
</para>
<para>
TODO : manage "."
</para>
<para>
TODO : manage ".."
</para>
<para>
TODO : manage relative files
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
file_normalize ( "/foo/myfile.txt" )
expected = "/foo/bla/myfile.txt";
//
file_normalize ( "\foo\myfile.txt" )
expected = "/foo/bla/myfile.txt";
]]></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>
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_normalize.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_normalize" 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_normalize</refname><refpurpose>Returns a unique normalized path.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
name : a 1-by-1 matrix of strings
path : a 1-by-1 matrix of strings
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>
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.
A normalized path
is an absolute path which has all '../', './' removed. Also it is one which
is in the ``standard'' format for the native platform.
On Windows or Mac, any platform-specific separator in the path
is replaced by the platform-independent separator "/".
On Windows it also means we want the long form with that form's
case-dependence (which gives us a unique, case-dependent path).
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
file_normalize ( "/foo/myfile.txt" )
expected = "/foo/bla/myfile.txt";
//
file_normalize ( "\foo\myfile.txt" )
expected = "/foo/bla/myfile.txt";
//
file_normalize ( "." )
expected = pwd()
//
file_normalize ( ".." )
//
file_normalize ( "../file.txt" )
]]></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>
help/en_US/update_help.sce
233233
234234
235235
236
237
236238
237239
238240
"file_tempfile"
"file_touch"
"file_separator"
"file_isfile"
"file_isdirectory"
];
macrosdir = cwd +"../../macros";
demosdir = cwd +"../../demos";
help/en_US/file_isfile.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_isfile.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_isfile" 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_isfile</refname><refpurpose>Returns %t if the path is a file.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
name : a 1-by-1 matrix of strings
tf : a 1-by-1 matrix of booleans
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>
Returns %t if the name is a file, %f if not.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
file_isfile ( filejoin([SCI,"etc","scilab.start"] ) // %t
file_isfile ( TMPDIR ) // %f
]]></programlisting>
</refsection>
<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Copyright (C) 2010 - DIGITEO - Michael Baudin</member>
</simplelist>
</refsection>
</refentry>
help/en_US/file_split.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
68
69
70
71
72
73
74
75
76
77
78
79
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_split.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_split" 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_split</refname><refpurpose>Split the path into a matrix of strings.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
pathmat = file_split ( name )
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry><term>name :</term>
<listitem><para> a 1-by-1 matrix of strings</para></listitem></varlistentry>
<varlistentry><term>pathmat :</term>
<listitem><para> a n-by-1 matrix of strings</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Returns a matrox of strings whose elements are the path components in name.
The first element of the list will have the same path type as name.
All other elements will be relative.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
name = file_tempfile ( )
pathmat = file_split ( name )
//
pathmat = file_split ( "/foo/myfile.txt" )
expected = ["/";"foo";"myfile.txt"]
//
pathmat = file_split ( "C:\foo\myfile.txt" )
expected_Windows = ["C:\";"foo";"myfile.txt"]
//
pathmat = file_split ( "C:/foo/myfile.txt" )
expected_Windows = ["C:/";"foo";"myfile.txt"]
]]></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>
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from file_split.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="file_split" 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_split</refname><refpurpose>Split the path into a matrix of strings.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
pathmat = file_split ( name )
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry><term>name :</term>
<listitem><para> a 1-by-1 matrix of strings</para></listitem></varlistentry>
<varlistentry><term>pathmat :</term>
<listitem><para> a n-by-1 matrix of strings</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Returns a matrox of strings whose elements are the path components in name.
The first element of the list will have the same path type as name.
All other elements will be relative.
</para>
<para>
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
name = file_tempfile ( )
pathmat = file_split ( name )
//
pathmat = file_split ( "/foo/myfile.txt" )
expected = ["/";"foo";"myfile.txt"]
//
pathmat = file_split ( "C:\foo\myfile.txt" )
expected_Windows = ["C:\";"foo";"myfile.txt"]
expected_Linux = "C:\foo\myfile.txt"
//
pathmat = file_split ( "C:/foo/myfile.txt" )
expected_Windows = ["C:/";"foo";"myfile.txt"]
expected_Linux = ["C:";"foo";"myfile.txt"]
]]></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
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
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
File Toolbox
Purpose
-------
The goal of this toolbox is to provide a collection of
functions to manage files.
The main objective is to provide a more consistent API than
Scilab does.
For example the Scilab/fullfile function is of limited use.
Indeed, if the various parts of a file are gathere in a matrix of
strings pathmatrix, the calling sequence fullfile(pathmatrix) will not work.
By contrast, the calling sequence fullfile(path1,path2,path3) can
be straighforwardly converted to the call file_join([path1,path2,path3]).
The file_tempfile function is not provided by Scilab.
It is often used in unit tests, where we need to create
unique temporary files.
The Scilab/copyfile is renamed into file_copy, which is consistent with
the naming convention chosen in the current module.
By contrast, Scilab uses a weird naming convention: the function, Scilab/fileext
begins by "file", while Scilab/deletefile ends by "file.
Features
-------
The following is a list of the current functions :
* file_join : Join sub-paths from a matrix of strings.
* file_nativename : Returns the platform-specific name of a path.
* file_normalize : Returns a unique normalized path.
* file_pathtype : Returns the type of a path.
* file_split : Split the path into a matrix of strings.
* file_tempfile : Returns the name of a temporary file name suitable for writing.
* file_touch : Alter the atime and mtime of the specified files.
Bibliography
------------
* 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
----
* Update the unit tests of join, split for Linux.
* integrate, rename and redesign the interesting functions from Scilab.
* This module should depend on the apifun module.
* Add unit tests.
* Add file_copy (from Scilab/copyfile)
* Add file_delete (from Scilab/deletefile and Scilab/removedir and Scilab/rmdir)
* Add file_dirname
* Add file_isfile
* Add file_isdir
* Add file_extension
* Add file_executable
* Add file_mkdir (from Scilab/createdir)
* Add file_mtime (from Scilab/fileinfo)
* Add file_rename
* Add file_size
* Add file_stat
* Add file_tail
* Add file_volumes (from Scilab/getdrives)
* Add file_writable
Author
------
* Copyright (C) 2010 - DIGITEO - Michael Baudin
* Copyright (c) 2008 - Michael Baudin
* Copyright (c) 2008 - Arjen Markus
Licence
-------
This toolbox is released under the CeCILL_V2 licence :
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
File Toolbox
Purpose
-------
The goal of this toolbox is to provide a collection of
functions to manage files.
The main objective is to provide a more consistent API than
Scilab does.
For example the Scilab/fullfile function is of limited use.
Indeed, if the various parts of a file are gathere in a matrix of
strings pathmatrix, the calling sequence fullfile(pathmatrix) will not work.
By contrast, the calling sequence fullfile(path1,path2,path3) can
be straighforwardly converted to the call file_join([path1,path2,path3]).
The file_tempfile function is not provided by Scilab.
It is often used in unit tests, where we need to create
unique temporary files.
The Scilab/copyfile is renamed into file_copy, which is consistent with
the naming convention chosen in the current module.
By contrast, Scilab uses a weird naming convention: the function, Scilab/fileext
begins by "file", while Scilab/deletefile ends by "file.
Features
-------
The following is a list of the current functions :
* file_join : Join sub-paths from a matrix of strings.
* file_nativename : Returns the platform-specific name of a path.
* file_normalize : Returns a unique normalized path.
* file_pathtype : Returns the type of a path.
* file_split : Split the path into a matrix of strings.
* file_tempfile : Returns the name of a temporary file name suitable for writing.
* file_touch : Alter the atime and mtime of the specified files.
Bibliography
------------
* 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
----
* integrate, rename and redesign the interesting functions from Scilab.
* This module should depend on the apifun module.
* Add unit tests.
* Add file_copy (from Scilab/copyfile)
* Add file_delete (from Scilab/deletefile and Scilab/removedir and Scilab/rmdir)
* Add file_dirname
* Add file_isfile
* Add file_isdir
* Add file_extension
* Add file_executable
* Add file_mkdir (from Scilab/createdir)
* Add file_mtime (from Scilab/fileinfo)
* Add file_rename
* Add file_size
* Add file_stat
* Add file_tail
* Add file_volumes (from Scilab/getdrives)
* Add file_writable
Author
------
* Copyright (C) 2010 - DIGITEO - Michael Baudin
* Copyright (c) 2008 - Michael Baudin
* Copyright (c) 2008 - Arjen Markus
Licence
-------
This toolbox is released under the CeCILL_V2 licence :
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt

Archive Download the corresponding diff file

Revision: 14