Mercurial > hg > octave-lyh
comparison scripts/path/savepath.m @ 5736:e07baa8b93b9
[project @ 2006-04-04 19:41:45 by jwe]
author | jwe |
---|---|
date | Tue, 04 Apr 2006 19:41:45 +0000 |
parents | 3a89e82677f0 |
children | 296cefb48d7e |
comparison
equal
deleted
inserted
replaced
5735:3a89e82677f0 | 5736:e07baa8b93b9 |
---|---|
23 ## default initilization file or optionally the @var{file} that you | 23 ## default initilization file or optionally the @var{file} that you |
24 ## specify. | 24 ## specify. |
25 ## | 25 ## |
26 ## It will return 0 if it was successful. | 26 ## It will return 0 if it was successful. |
27 ## | 27 ## |
28 ## @seealso{LOADPATH, addpath, rmpath} | 28 ## @seealso{LOADPATH, addpath, rmpath, setpath} |
29 ## @end deftypefn | 29 ## @end deftypefn |
30 | 30 |
31 ## Author: Bill Denney <bill@givebillmoney.com> | 31 ## Author: Bill Denney <bill@givebillmoney.com> |
32 | |
33 ##PKGADD: mark_as_command savepath | |
32 | 34 |
33 function varargout = savepath (savefile) | 35 function varargout = savepath (savefile) |
34 | 36 |
35 retval = 1; | 37 retval = 1; |
36 | 38 |
77 | 79 |
78 if (startline > endline || (startline > 0 && endline == 0)) | 80 if (startline > endline || (startline > 0 && endline == 0)) |
79 error ("savepath: unable to parse file, %s", savefile); | 81 error ("savepath: unable to parse file, %s", savefile); |
80 endif | 82 endif |
81 | 83 |
82 ## put the path into a cell array | |
83 pathlines = { beginstring, [" LOADPATH=\"", LOADPATH, "\";"], endstring }; | |
84 | |
85 ## put the current savepath lines into the file | 84 ## put the current savepath lines into the file |
86 if (isempty (filelines) | 85 if (isempty (filelines) |
87 || (startline == 1 && endline == length (filelines))) | 86 || (startline == 1 && endline == length (filelines))) |
88 ## savepath is the entire file | 87 ## savepath is the entire file |
89 pre = post = {}; | 88 pre = post = {}; |
109 error ("savepath: unable to open file for writing, %s, %s", savefile, msg); | 108 error ("savepath: unable to open file for writing, %s, %s", savefile, msg); |
110 end | 109 end |
111 for i = 1:length (pre) | 110 for i = 1:length (pre) |
112 fprintf (fid, "%s\n", pre{i}) | 111 fprintf (fid, "%s\n", pre{i}) |
113 endfor | 112 endfor |
114 for i = 1:length (pathlines) | 113 |
115 fprintf (fid, "%s\n", pathlines{i}); | 114 fprintf (fid, "%s\n setpath (\"%s\");\n%s\n", |
116 endfor | 115 beginstring, LOADPATH, endstring); |
116 | |
117 for i = 1:length (post) | 117 for i = 1:length (post) |
118 fprintf (fid, "%s\n", post{i}); | 118 fprintf (fid, "%s\n", post{i}); |
119 endfor | 119 endfor |
120 closeread = fclose (fid); | 120 closeread = fclose (fid); |
121 if (closeread < 0) | 121 if (closeread < 0) |