0001 function [] = fname_edit(obj, eventdata, dialog)
0002
0003
0004
0005
0006
0007
0008
0009 this = get(dialog, 'UserData');
0010 fname = deblank( get(obj, 'String') );
0011
0012
0013
0014 err = false;
0015 current_dir = this.public.current_dir;
0016 f_path = fname;
0017 if isdir([current_dir, filesep, f_path])
0018
0019 f_path = [current_dir, filesep, f_path];
0020 elseif isdir([pwd, filesep, f_path])
0021
0022 err = true;
0023 elseif isdir(f_path)
0024
0025 else
0026 err = true;
0027 end
0028
0029 if ~err
0030
0031 tmp = pwd;
0032 cd(f_path);
0033 f_path = pwd;
0034 cd(tmp);
0035 if strcmp(f_path(length(f_path)), filesep)
0036 f_path = f_path(1:length(f_path)-1);
0037 end
0038
0039 this.public.current_dir = f_path;
0040
0041 if ispc
0042 ix = strfind(f_path, ':');
0043 if ~isempty(ix)
0044 drive = f_path(1:ix);
0045 drive_list = {this.private.drive_info.drive};
0046 ix_list = strmatch(drive, drive_list);
0047 if ~isempty(ix_list)
0048 this.private.current_drive = ix_list;
0049 end
0050 end
0051 end
0052 fname = [];
0053 else
0054
0055 [f_path, f_name, f_ext] = fileparts(fname);
0056 fname = [f_name, f_ext];
0057 end
0058
0059 if this.public.save_mode
0060 current_extension = get(this.private.gui_handles.extension_popup, 'Value');
0061 file_extension = this.public.file_extensions{current_extension};
0062
0063 this.private.current_file = {};
0064 if length(fname)
0065
0066 flg = 1;
0067 if strcmp(file_extension, '.*')
0068 flg = 0;
0069 else
0070 if length(fname) > length(file_extension)
0071 tmp = length(fname) - length(file_extension) + 1;
0072 if strcmp(fname(tmp:length(fname)), file_extension)
0073 flg = 0;
0074 end
0075 end
0076 end
0077
0078 if flg == 1, fname = [fname, file_extension]; end
0079
0080 this.private.current_file{1} = fname;
0081 end
0082 end
0083
0084
0085 set(dialog, 'UserData', this);
0086 set_gui_property(dialog);