1 | # This program is under CECILL_B licence. See footer for details. |
---|
2 | |
---|
3 | proc getRecentProjects {} { |
---|
4 | global configPath |
---|
5 | set recentPath [file join [file dirname $configPath] "recents.xml"] |
---|
6 | # Test if the file already exists |
---|
7 | if [file exists $recentPath] { |
---|
8 | # Loads the file |
---|
9 | set tree "" |
---|
10 | dTree_init tree |
---|
11 | parseFile $recentPath tree "" "DStree" |
---|
12 | |
---|
13 | # Transforms old recents.xml version into the new one |
---|
14 | if {[dTree_nodeExists $tree "root recents"] == 0 } { |
---|
15 | debug "dataset does not exist" |
---|
16 | foreach child [dTree_getChildren $tree "root" ] { |
---|
17 | dTree_moveBranch tree "root $child" tree "root recents" |
---|
18 | } |
---|
19 | } |
---|
20 | |
---|
21 | return $tree |
---|
22 | } else { |
---|
23 | # Create the file |
---|
24 | set tree "" |
---|
25 | dTree_init tree |
---|
26 | dTree_addNode tree "root" "recents" |
---|
27 | #saveXMLTree $recentPath $tree |
---|
28 | return $tree |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | proc newRecentProject {XMLfile code} { |
---|
33 | global topPath |
---|
34 | set recentPath [file join $topPath "recents.xml"] |
---|
35 | set XMLfile [file normalize $XMLfile] |
---|
36 | # Test if the file already exists |
---|
37 | |
---|
38 | # Loads the file |
---|
39 | set tree "" |
---|
40 | dTree_init tree |
---|
41 | |
---|
42 | if [file exists $recentPath] { |
---|
43 | parseFile $recentPath tree "" "DStree" |
---|
44 | # Transforms old recents.xml version into the new one |
---|
45 | if {[dTree_nodeExists $tree "root recents"] == 0 } { |
---|
46 | |
---|
47 | foreach child [dTree_getChildren $tree "root" ] { |
---|
48 | dTree_moveBranch tree "root $child" tree "root recents" |
---|
49 | } |
---|
50 | } |
---|
51 | foreach elt [dTree_getChildren $tree "root recents"] { |
---|
52 | if {[dTree_getAttribute $tree "root recents $elt" "path"] == $XMLfile} { |
---|
53 | dTree_rmNode tree "root recents $elt" |
---|
54 | } |
---|
55 | } |
---|
56 | } else { |
---|
57 | dTree_addNode tree "root" "recents" |
---|
58 | } |
---|
59 | |
---|
60 | set id [clock seconds] |
---|
61 | dTree_addNode tree "root recents" $id |
---|
62 | dTree_setAttribute tree "root recents $id" "path" $XMLfile |
---|
63 | dTree_setAttribute tree "root recents $id" "code" $code |
---|
64 | |
---|
65 | #saveXMLTree $recentPath $tree |
---|
66 | |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | # Copyright CERFACS 2014 |
---|
71 | # |
---|
72 | # antoine.dauptain@cerfacs.fr |
---|
73 | # |
---|
74 | # This software is a computer program whose purpose is to ensure technology |
---|
75 | # transfer between academia and industry. |
---|
76 | # |
---|
77 | # This software is governed by the CeCILL-B license under French law and |
---|
78 | # abiding by the rules of distribution of free software. You can use, |
---|
79 | # modify and/ or redistribute the software under the terms of the CeCILL-B |
---|
80 | # license as circulated by CEA, CNRS and INRIA at the following URL |
---|
81 | # "http://www.cecill.info". |
---|
82 | # |
---|
83 | # As a counterpart to the access to the source code and rights to copy, |
---|
84 | # modify and redistribute granted by the license, users are provided only |
---|
85 | # with a limited warranty and the software's author, the holder of the |
---|
86 | # economic rights, and the successive licensors have only limited |
---|
87 | # liability. |
---|
88 | # |
---|
89 | # In this respect, the user's attention is drawn to the risks associated |
---|
90 | # with loading, using, modifying and/or developing or reproducing the |
---|
91 | # software by the user in light of its specific status of free software, |
---|
92 | # that may mean that it is complicated to manipulate, and that also |
---|
93 | # therefore means that it is reserved for developers and experienced |
---|
94 | # professionals having in-depth computer knowledge. Users are therefore |
---|
95 | # encouraged to load and test the software's suitability as regards their |
---|
96 | # requirements in conditions enabling the security of their systems and/or |
---|
97 | # data to be ensured and, more generally, to use and operate it in the |
---|
98 | # same conditions as regards security. |
---|
99 | # |
---|
100 | # The fact that you are presently reading this means that you have had |
---|
101 | # knowledge of the CeCILL-B license and that you accept its terms. |
---|