Mercurial > hg > octave-nkf
changeset 19557:7c31a83e25bc gui-release
uiputfile: add extension to file name (Bug #43687)
* scripts/gui/private/__file_filter__.m
(__file_filter__): Dont add *.* filter so default only is used.
* scripts/gui/uiputfile.m:
(uiputfile): check if file name has extension and add if needed
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Tue, 25 Nov 2014 12:45:36 -0500 |
parents | 76b4256bcbd8 |
children | 8d267cca249e |
files | scripts/gui/private/__file_filter__.m scripts/gui/uiputfile.m |
diffstat | 2 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/gui/private/__file_filter__.m +++ b/scripts/gui/private/__file_filter__.m @@ -53,7 +53,7 @@ if (! strcmp (fname, "*")) defname = strcat (fname, fext); endif - if (length (fext) > 0) + if ((length (fext) > 0) && (! strcmp(fext, '.*'))) fext = strcat ("*", fext); retval = {fext, __default_filtername__(fext)}; endif
--- a/scripts/gui/uiputfile.m +++ b/scripts/gui/uiputfile.m @@ -125,6 +125,19 @@ [retfile, retpath, retindex] = feval (funcname, outargs{:}); endif + # add extension to the name it isnt already added + + if ischar (retfile) + ext = outargs{1}{retindex}; + ext = strrep (ext, '*', ''); + + if length (retfile) >= length (ext) + if ! strcmp (retfile(end-length (ext)+1:end), ext) + retfile = [retfile ext]; + endif + endif + endif + endfunction