diff options
Diffstat (limited to 'modules/fileio/macros')
35 files changed, 2246 insertions, 0 deletions
diff --git a/modules/fileio/macros/%_listvarinfile.bin b/modules/fileio/macros/%_listvarinfile.bin Binary files differnew file mode 100755 index 000000000..f8204d025 --- /dev/null +++ b/modules/fileio/macros/%_listvarinfile.bin diff --git a/modules/fileio/macros/%_listvarinfile.sci b/modules/fileio/macros/%_listvarinfile.sci new file mode 100755 index 000000000..1dbc56305 --- /dev/null +++ b/modules/fileio/macros/%_listvarinfile.sci @@ -0,0 +1,1361 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2001 - INRIA - Serge Steer +// Copyright (C) Enrico Segre +// +// 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.1-en.txt + +// set of functions for getting information about variables saved in a Scilab +// data file + +function varargout=%_listvarinfile(fil) + lhs=argn(1) + u=mopen(fil,"rb") + typenames=[ // in vector form, in order to cover the first 17 + "constant"; + "polynomial"; + "???" + "boolean"; + "sparse"; + "boolean sparse"; + "Matlab sparse"; + "integer" + "graphic handle"; //not yet done + "string"; + "function"; + "???" + "function"; + "library"; + "list" + "tlist" + "mlist"] + + + nams=[] + dims=list() + typs=[];vols=[] + + if lhs==1 then + //write the display header + write(%io(2),part("Name",1:25)+ part("Type",1:15)+part("Size",1:16)+.. + part("Bytes",1:10)) + write(%io(2),"---------------------------------------------------------------") + end + + while %t + w=mget(6,"il",u) + if size(w,"*")<6|meof(u)<>0 then break,end + nam=code2var(w); + + [typ,dim,vol]=listnextvar(u) + if typ<=17 then + typn=typenames(typ) + elseif typ==128 then + typn="pointer"; + elseif typ==129 then + typn="size implicit"; + elseif typ==130 then + typn="primitive"; + else + error(msprintf(gettext("%s: Wrong variable type (%s) found in ''%s''. File may be wrong or corrupted.\n"), "listvarinfile", string(typ), fil)) + end + + if lhs==1 then + if typ <>128 & typ <> 130 then + write(%io(2),part(nam,1:25)+part(typn,1:15)+.. + part(strcat(string(dim)," by "),1:16)+part(string(vol),1:10)) + else //types 9, 128 and 130 are known in scilab, but their API is unpublished + write(%io(2),part(nam,1:25)+part(typn,1:15)+"unknown unknown") + warning(".... unknown structure, I''m forced to stop here (bug 2387)") + end + end + typs=[typs;typ] + dims($+1)=dim + nams=[nams;nam] + vols=[vols;vol] + if dim==-1 | vol==-1 then break; end // this for types with unknown API + end + mclose(u) + + varargout=list(nams,typs,dims,vols) +endfunction + +///////////////////////////////////////////////// + +function [typ,dim,vol]=listnextvar(u) + typ=mget(1,"il",u) //The variable type + dim=-1;vol=-1; //flags to break the caller loop in unknown cases + select typ + case 1 then //matrix of numbers + w=mget(3,"il",u) //header of the variable + m=w(1);n=w(2);it=w(3);dim=[m,n] + N=m*n*(it+1) + mseek(8*N,u,"cur") //skip the values + //A=mget(N,"dl",u) + vol=4*4+8*N + case 2 then //polynomial + w=mget(3,"il",u) //header of the variable + m=w(1);n=w(2);it=w(3);dim=[m,n] + mseek(4*4,u,"cur") //skeep the formal variable name + w=mget(m*n+1,"il",u) //get the pointer table + //I=mget(m*n+1,"il",u) + N=(w(m*n+1)-1)*(it+1) + mseek(8*N,u,"cur") //skip the values + //A=mget(N,"dl",u) + vol=(4+4+(m*n+1))*4+8*N + case 4 then //boolean + w=mget(2,"il",u) //header of the variable + m=w(1);n=w(2);dim=[m,n] + N=m*n + mseek(4*N,u,"cur") // skip the values + //A=mget(N,"il",u) + vol=(4+N)*4 + case 5 then //sparse + w=mget(4,"il",u) //header of the variable + m=w(1);n=w(2);it=w(3);nel=w(4);dim=[m,n] + mseek(4*(m+nel),u,"cur")// skip the index + mseek(8*nel*(it+1),u,"cur") // skip the non zero values + //I=mget(((m+nel),"il",u) + //A=mget((nel*(it+1)),"dl",u) + vol=(5+m+nel)*4+8*nel*(it+1) + case 6 then //boolean sparse + w=mget(4,"il",u) //header of the variable + m=w(1);n=w(2);it=w(3);nel=w(4);dim=[m,n] + mseek(4*(m+nel),u,"cur")// skip the index + //I=mget((m+nel),"il",u) + vol=(5+m+nel)*4 + case 8 then //integer + w=mget(3,"il",u) //header of the variable + m=w(1);n=w(2);it=w(3);dim=[m,n] + select it + case 4 then + mseek(m*n*4,u,"cur") + //A=mget((m*n,"il",u) + vol=4*4+m*n*4 + case 2 then + mseek(m*n*2,u,"cur") + //A=mget((m*n,"sl",u) + vol=4*4+m*n*2 + case 1 then + mseek(m*n*1,u,"cur") + //A=mget((m*n,"c",u) + vol=4*4+m*n + case 14 then + mseek(m*n*4,u,"cur") + //A=mget((m*n,"uil",u) + vol=4*4+m*n*4 + case 12 then + mseek(m*n*2,u,"cur") + //A=mget((m*n,"usl",u) + vol=4*4+m*n*2 + case 11 then + mseek(m*n*1,u,"cur") + //A=mget((m*n,"uc",u) + vol=4*4+m*n + end + case 9 then //graphic handle: API?? + [dim, vol] = getMatrixHandleInfo(u); + case 10 then //string + w=mget(3,"il",u) + m=w(1);n=w(2);it=w(3);dim=[m,n] + w=mget(m*n+1,"il",u) //get the pointer table + N=w($)-1 //total number of chars + mseek(4*N,u,"cur") //skip the values, N characters coded in N integers + vol=(4*m*n+1)*4+4*N + case 11 then // function (not compiled) + dim=[] + nout=mget(1,"il",u) + mseek(nout*6*4,u,"cur") //skip lhs names, nout names coded over 6 integers + nin=mget(1,"il",u) + mseek(nin*6*4,u,"cur") //skip rhs names, nin names coded over 6 integers + N=mget(1,"il",u) //code length + mseek(N*4,u,"cur") //skip code (N characters coded in N integers) + vol=(3+(nin+nout)*6+N)*4 + case 13 then // compiled function + dim=[] + nout=mget(1,"il",u) + mseek(nout*6*4,u,"cur") //skip lhs names, nout names coded over 6 integers + nin=mget(1,"il",u) + mseek(nin*6*4,u,"cur") //skip rhs names, nin names coded over 6 integers + N=mget(1,"il",u) //code length + mseek(N*4,u,"cur") //skip pseudo-code N integers + vol=(3+(nin+nout)*6+N)*4 + case 14 then //library + np=mget(1,"il",u) //path length + mseek(np*4,u,"cur") //skeep the path + nclas=29 + nn=mget(1,"il",u) //number of names + dim=nn + mseek((nclas+1)*4,u,"cur") //skeep the class pointers + mseek(nn*6*4,u,"cur") //skip the names + vol=(2+np+1+nclas+1+nn*6)*4 + case 15 then //list + [dim, vol] = getListInfo(u); + case 16 then //tlist + [dim, vol] = getListInfo(u); + case 17 then //mlist + [dim, vol] = getListInfo(u); + case 128 then //pointer: API?? + + case 129 then //size implicit index (same as polynomial) + w=mget(3,"il",u) //header of the variable + m=w(1);n=w(2);it=w(3);dim=[m,n] + mseek(4*4,u,"cur") //skeep the formal variable name + w=mget(m*n+1,"il",u) //get the pointer table + //I=mget(m*n+1,"il",u) + N=(w(m*n+1)-1)*(it+1) + mseek(8*N,u,"cur") //skip the values + //A=mget(N,"dl",u) + vol=(4+4+(m*n+1))*4+8*N + case 130 then //scilab primitive: API?? + + else //unknown type, or file content plainly wrong + + end +endfunction + +////////////////////////////////////////////////////////// +function [items, totalSize] = getListInfo(file_descriptor) + items = mget(1, "il", file_descriptor);//read item count + offset = mget(1 + items, "il", file_descriptor);//read offset between vars + totalSize = (2 + (items + 1)) * 4; + for i = 1:items + //bypass Undefined item + if offset(i) <> offset(i + 1) then + [t, d, v] = listnextvar(file_descriptor); + totalSize = totalSize + v; + end + end +endfunction + +////////////////////////////////////////////////////////// +function [hsize, totalSize] = getMatrixHandleInfo(fd) + totalSize = 4 + 4; + version=mget(4, "uc", fd); + if is_higher_than([3 1 0 1]) then // case 3 1 0 2 and after + hsize = mget(2, "uc", fd) + totalSize = totalSize + 2; + for i=1:hsize(1) + for j=1:hsize(2) + totalSize = getSingleHandleInfo(fd, totalSize) + end + end + else + // a single handle only can be loaded before 3 1 0 2 + hsize = [1,1]; + totalSize = getSingleHandleInfo(fd, totalSize); + end + +endfunction + +////////////////////////////////////////////////////////// +function totalSize = getSingleHandleInfo(fd, totalSize) + [totalSize, handleType] = readString(fd, totalSize); // Type + + select handleType + case "Figure" + totalSize = seekBool(fd, totalSize); // Visible + totalSize = seekShortCount(fd, 2, totalSize); //figure_position + totalSize = seekShortCount(fd, 2, totalSize); //figure_size + totalSize = seekShortCount(fd, 2, totalSize); //axes_size + if is_higher_than( [4 1 2 0] ) then + totalSize = seekShortCount(fd, 2, totalSize); //viewport + if is_higher_than([5 4 0 0]) then + totalSize = seekStringInt(fd, totalSize); // info_message + else + totalSize = seekString(fd, totalSize); // info_message + end + totalSize = seekString(fd, totalSize); // tag + end + + totalSize = seekBool(fd, totalSize); // auto_resize + if is_higher_than([5 4 0 0]) then + totalSize = seekStringInt(fd, totalSize); // figure_name + else + totalSize = seekString(fd, totalSize); // figure_name + end + totalSize = seekShort(fd, totalSize); //figure_id + totalSize = seekMatrix(fd, totalSize); // color_map + if ~is_higher_than([5 4 0 1]) then + totalSize = seekBool(fd, totalSize); // pixmap + end + totalSize = seekString(fd, totalSize); // pixel_drawing_mode + if (is_higher_than([5 1 0 0])) then + totalSize = seekString(fd, totalSize); // anti_aliasing + end + totalSize = seekBool(fd, totalSize); // immediate_drawing + totalSize = seekInt(fd, totalSize); // background + totalSize = seekString(fd, totalSize); // rotation_style + if ( is_higher_than([4 1 2 0]) ) then + totalSize = seekString(fd, totalSize); // event_handler + totalSize = seekString(fd, totalSize); // event_handler_enable + end + if ( is_higher_than([5 2 0 0]) ) then // Added in 5.4.0 version + totalSize = seekString(fd, totalSize); // resizefcn + totalSize = seekString(fd, totalSize); // closerequestfcn + end + + [totalSize, axesCount] = readInt(fd, totalSize); // children + for i = 1 : axesCount + totalSize = getSingleHandleInfo(fd, totalSize); + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Axes" + totalSize = seekBool(fd, totalSize); // visible + if and(version==[3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // axes_visible + else + totalSize = seekBoolMatrix(fd, totalSize); // axes_visible + end + + if is_higher_than( [3 1 0 1] ) then + totalSize = seekBoolMatrix(fd, totalSize); // axes_reverse + end + + totalSize = seekIntMatrix(fd, totalSize); // grid + if (is_higher_than([5 0 3 0])) then + totalSize = seekString(fd, totalSize); // grid_position + end + totalSize = seekString(fd, totalSize); // x_location + totalSize = seekString(fd, totalSize); // y_location + [totalSize, view] = readStringCount(fd, 2, totalSize); // view + + //title + totalSize = seekBool(fd, totalSize); // visible + if is_higher_than( [4 1 2 0] ) then + totalSize = seekStringMatrix(fd, totalSize); // text + else + totalSize = seekString(fd, totalSize); // text + end + + if is_higher_than([4 1 2 0]) then + totalSize = seekInt(fd, totalSize); // font_foreground + totalSize = seekBool(fd, totalSize); // fractional_font + end + + totalSize = seekInt(fd, totalSize); // foreground + if is_higher_than([3 1 0 0]) then + totalSize = seekInt(fd, totalSize); // background + totalSize = seekBool(fd, totalSize); // fill_mode + end + + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + + if is_higher_than([3 1 0 0]) then + totalSize = seekBool(fd, totalSize); // auto_rotation + totalSize = seekDouble(fd, totalSize); // font_angle + totalSize = seekBool(fd, totalSize); // auto_position + totalSize = seekDouble(fd, totalSize); // position 1 + totalSize = seekDouble(fd, totalSize); // position 2 + end + + //x_label + totalSize = seekBool(fd, totalSize); // visible + if is_higher_than( [4 1 2 0] ) then + totalSize = seekStringMatrix(fd, totalSize); // text + else + totalSize = seekString(fd, totalSize); // text + end + + if is_higher_than([4 1 2 0]) then + totalSize = seekInt(fd, totalSize); // font_foreground + totalSize = seekBool(fd, totalSize); // fractional_font + end + + totalSize = seekInt(fd, totalSize); // foreground + if is_higher_than([3 0 0 0]) then + totalSize = seekInt(fd, totalSize); // background + totalSize = seekBool(fd, totalSize); // fill_mode + end + + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // auto_rotation + totalSize = seekDouble(fd, totalSize); // font_angle + totalSize = seekBool(fd, totalSize); // auto_position + totalSize = seekDouble(fd, totalSize); // position 1 + totalSize = seekDouble(fd, totalSize); // position 2 + end + + //y_label + totalSize = seekBool(fd, totalSize); // visible + if is_higher_than( [4 1 2 0] ) then + totalSize = seekStringMatrix(fd, totalSize); // text + else + totalSize = seekString(fd, totalSize); // text + end + + if is_higher_than([4 1 2 0]) then + totalSize = seekInt(fd, totalSize); // font_foreground + totalSize = seekBool(fd, totalSize); // fractional_font + end + + totalSize = seekInt(fd, totalSize); // foreground + if is_higher_than([3 0 0 0]) then + totalSize = seekInt(fd, totalSize); // background + totalSize = seekBool(fd, totalSize); // fill_mode + end + + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // auto_rotation + totalSize = seekDouble(fd, totalSize); // font_angle + totalSize = seekBool(fd, totalSize); // auto_position + totalSize = seekDouble(fd, totalSize); // position 1 + totalSize = seekDouble(fd, totalSize); // position 2 + end + + if view == "3d" then + //z_label + totalSize = seekBool(fd, totalSize); // visible + if is_higher_than( [4 1 2 0] ) then + totalSize = seekStringMatrix(fd, totalSize); // text + else + totalSize = seekString(fd, totalSize); // text + end + + if is_higher_than([4 1 2 0]) then + totalSize = seekInt(fd, totalSize); // font_foreground + totalSize = seekBool(fd, totalSize); // fractional_font + end + + totalSize = seekInt(fd, totalSize); // foreground + if is_higher_than([3 0 0 0]) then + totalSize = seekInt(fd, totalSize); // background + totalSize = seekBool(fd, totalSize); // fill_mode + end + + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // auto_rotation + totalSize = seekDouble(fd, totalSize); // font_angle + totalSize = seekBool(fd, totalSize); // auto_position + totalSize = seekDouble(fd, totalSize); // position 1 + totalSize = seekDouble(fd, totalSize); // position 2 + end + end + + if is_higher_than([3 0 0 0]) then + totalSize = seekBoolMatrix(fd, totalSize); // auto_ticks + + //x_ticks + [totalSize, ticksX] = readShort(fd, totalSize); // ticks count + if ticksX > 0 then + totalSize = seekMatrixCount(fd, ticksX, totalSize); // locations + [totalSize, labels] = readBoolCount(fd, ticksX, totalSize); // label + for i = 1:ticksX + totalSize = seekStringCount(fd, labels(i), totalSize); + end + end + + //y_ticks + [totalSize, ticksY] = readShort(fd, totalSize); // ticks count + if ticksY > 0 then + totalSize = seekMatrixCount(fd, ticksY, totalSize); // locations + [totalSize, labels] = readBoolCount(fd, ticksY, totalSize); // label + for i = 1:ticksY + totalSize = seekStringCount(fd, labels(i), totalSize); + end + end + + //z_ticks + [totalSize, ticksZ] = readShort(fd, totalSize); // ticks count + if ticksZ > 0 then + totalSize = seekMatrixCount(fd, ticksZ, totalSize); // locations + [totalSize, labels] = readBoolCount(fd, ticksZ, totalSize); // label + for i = 1:ticksZ + totalSize = seekStringCount(fd, labels(i), totalSize); + end + end + end + + if is_higher_than([4 1 2 0]) then + totalSize = seekString(fd, totalSize); // box + totalSize = seekBool(fd, totalSize); // filled + else + totalSize = seekBool(fd, totalSize); // box + end + + totalSize = seekString(fd, totalSize); // sub_ticks + + if ~(is_higher_than([3 1 0 1]) ) then + totalSize = seekDouble(fd, totalSize); // ticks_color + end + + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + totalSize = seekInt(fd, totalSize); // font_color + + if is_higher_than([4 1 2 0]) then + totalSize = seekBool(fd, totalSize); // fractional_font + end + + totalSize = seekBool(fd, totalSize); // isoview + totalSize = seekBool(fd, totalSize); // cube_scaling + totalSize = seekDouble(fd, totalSize); // rotation_angles 1 + totalSize = seekDouble(fd, totalSize); // rotation_angles 2 + + if is_higher_than([3 0 0 0]) then + totalSize = seekStringCount(fd, 3, totalSize); // log_flags + else + totalSize = seekStringCount(fd, 2, totalSize); // log_flags + end + + if is_higher_than([5 5 0 0]) then // tight_limits + totalSize = seekBoolMatrix(fd, totalSize); + else + totalSize = seekBool(fd, totalSize); + end + [totalSize, bounds] = readBool(fd, totalSize); // data_bounds count + totalSize = seekDoubleCount(fd, bounds, totalSize); // data_bounds + + if is_higher_than([3 0 0 0]) then + [totalSize, zooms] = readBool(fd, totalSize); // zoom_box_size + if zooms <> 0 then + totalSize = seekDoubleCount(fd, zooms, totalSize); // zoom_box + end + end + + if is_higher_than([3 1 0 1]) then + totalSize = seekDoubleCount(fd, 4, totalSize); // margins + end + + totalSize = seekDoubleCount(fd, 4, totalSize); // axes_bounds + totalSize = seekBool(fd, totalSize); // auto_clear + totalSize = seekBool(fd, totalSize); // auto_scale + + if is_higher_than([4 1 2 0] ) then + totalSize = seekInt(fd, totalSize); // hidden_axis_color + totalSize = seekString(fd, totalSize); // arc_drawing_method + end + + totalSize = seekInt(fd, totalSize); // hidden_color + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekBool(fd, totalSize); // line_style + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekBool(fd, totalSize); // mark_style + totalSize = seekBool(fd, totalSize); // mark_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // mark_size_unit + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + end + + totalSize = seekInt(fd, totalSize); // foreground + totalSize = seekInt(fd, totalSize); // background + [totalSize, clip] = readString(fd, totalSize); // clip_state + if clip == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); // clip_box + end + + global parentAxesView; + parentAxesView = view; + [totalSize, axesCount] = readInt(fd, totalSize); // children + for i = 1 : axesCount + totalSize = getSingleHandleInfo(fd, totalSize); + end + clearglobal parentAxesView; + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Polyline" + totalSize = seekBool(fd, totalSize); // visible + [totalSize, dataCount] = readIntCount(fd, 2, totalSize); // data count + totalSize = seekDoubleCount(fd, prod(dataCount), totalSize); // data + if is_higher_than([3 1 0 0]) then + totalSize = seekBool(fd, totalSize); // closed + end + + totalSize = seekBool(fd, totalSize); // line_mode + if is_higher_than([3 1 0 0]) then + totalSize = seekBool(fd, totalSize); // fill_mode + end + + totalSize = seekBool(fd, totalSize); // line_style + totalSize = seekShort(fd, totalSize); // thickness + if is_higher_than([3 1 0 1]) then + totalSize = seekShort(fd, totalSize); // arrow_size_factor + end + + totalSize = seekBool(fd, totalSize); // polyline_style + + if is_higher_than([3 1 0 1] ) then + [totalSize, count] = readShort(fd, totalSize); // interp_color_vector size + totalSize = seekDoubleCount(fd, count, totalSize); // interp_color_vector + totalSize = seekBool(fd, totalSize); // interp_color_mode + end + + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekBool(fd, totalSize); // mark_style + totalSize = seekBool(fd, totalSize); // mark_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // mark_size_unit + end + + totalSize = seekInt(fd, totalSize); // foreground + if is_higher_than([3 1 0 0]) then + totalSize = seekInt(fd, totalSize); // background + end + + if is_higher_than([3 0 0 0]) then + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + end + + if is_higher_than([3 1 0 0]) then + [totalSize, count] = readShort(fd, totalSize); // x_shift count + totalSize = seekDoubleCount(fd, count, totalSize); // x_shift + [totalSize, count] = readShort(fd, totalSize); // y_shift count + totalSize = seekDoubleCount(fd, count, totalSize); // y_shift + [totalSize, count] = readShort(fd, totalSize); // z_shift count + totalSize = seekDoubleCount(fd, count, totalSize); // z_shift + end + + if is_higher_than([3 1 0 1]) then + totalSize = seekDouble(fd, totalSize); // bar_width + end + + //totalSize = seekMatrix(fd, totalSize); // datatips + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Plot3d" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekBool(fd, totalSize); // surface_mode + totalSize = seekInt(fd, totalSize); // foreground + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekBool(fd, totalSize); // mark_style + totalSize = seekBool(fd, totalSize); // mark_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // mark_size_unit + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + end + + if is_higher_than([5 1 1 0]) then + totalSize = seekInt(fd, totalSize); // color_mode + [totalSize, flag] = readInt(fd, totalSize); // color_flag + else + totalSize = seekBool(fd, totalSize); // color_mode + [totalSize, flag] = readBool(fd, totalSize); // color_flag + end + + //data + totalSize = seekDoubleMatrix(fd, totalSize); // x + totalSize = seekDoubleMatrix(fd, totalSize); // y + totalSize = seekDoubleMatrix(fd, totalSize); // z + + if or(flag == [2,5]) then + [totalSize, count] = readIntCount(fd, 2, totalSize); // color size + totalSize = seekIntCount(fd, prod(count), totalSize); // color + end + + totalSize = seekInt(fd, totalSize); // hidden_color + + if is_higher_than([4 1 2 0]) + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Fac3d" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekBool(fd, totalSize); // surface_mode + totalSize = seekInt(fd, totalSize); // foreground + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekBool(fd, totalSize); // mark_style + totalSize = seekBool(fd, totalSize); // mark_size + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // mark_size_unit + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + end + + if is_higher_than([5 1 1 0]) then + totalSize = seekInt(fd, totalSize); // color_mode + [totalSize, flag] = readInt(fd, totalSize); // color_flag + else + totalSize = seekBool(fd, totalSize); // color_mode + [totalSize, flag] = readBool(fd, totalSize); // color_flag + end + + //data + totalSize = seekDoubleMatrix(fd, totalSize); // x + totalSize = seekDoubleMatrix(fd, totalSize); // y + totalSize = seekDoubleMatrix(fd, totalSize); // z + + if is_higher_than([3 1 0 1]) & flag >= 2 then + [totalSize, count] = readIntCount(fd, 2, totalSize); // color size + totalSize = seekIntCount(fd, prod(count), totalSize); // color + totalSize = seekBool(fd, totalSize); // cdata_mapping + elseif or(flag==[2 5]) then + [totalSize, count] = readIntCount(fd, 2, totalSize); // color size + totalSize = seekIntCount(fd, prod(count), totalSize); // color + end + + totalSize = seekInt(fd, totalSize); // color_mode + + if is_higher_than([4 1 2 0]) + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Compound" + [totalSize, count] = readInt(fd, totalSize); // children count + for i = 1 : count + totalSize = getSingleHandleInfo(fd, totalSize); // children + end + + if is_higher_than([3 1 0 1]) then + totalSize = readBool(fd, totalSize); // visible + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Agregation" + [totalSize, count] = readInt(fd, totalSize); // children count + for i = 1 : count + totalSize = getSingleHandleInfo(fd, totalSize); // children + end + + if is_higher_than([3 1 0 1]) then + totalSize = readBool(fd, totalSize); // visible + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Rectangle" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekBool(fd, totalSize); // mark_style + totalSize = seekBool(fd, totalSize); // mark_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // mark_size_unit + end + + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekBool(fd, totalSize); // line_style + totalSize = seekBool(fd, totalSize); // fill_mode + totalSize = seekInt(fd, totalSize); // foreground + + if is_higher_than([3 1 0 1]) then + totalSize = seekInt(fd, totalSize); // background + end + + if (is_higher_than([5 0 3 0])) then + totalSize = seekMatrix(fd, totalSize); // data + else + global parentAxesView; + if parentAxesView == [] | parentAxesView == "2d" then + totalSize = seekDoubleCount(fd, 4, totalSize); //data + else + totalSize = seekDoubleCount(fd, 5, totalSize); //data + end + end + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Arc" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekBool(fd, totalSize); // line_style + + if is_higher_than([3 1 0 1]) + totalSize = seekBool(fd, totalSize); // line_mode + end + + totalSize = seekBool(fd, totalSize); // fill_mode + totalSize = seekInt(fd, totalSize); // foreground + + if is_higher_than([3 1 0 1]) then + totalSize = seekInt(fd, totalSize); // background + end + + if is_higher_than([5 0 3 0]) then + totalSize = seekMatrix(fd, totalSize); // data + else + global parentAxesView; + if parentAxesView == [] | parentAxesView == "2d" then + totalSize = seekDoubleCount(fd, 6, totalSize); //data + else + totalSize = seekDoubleCount(fd, 7, totalSize); //data + end + end + + if is_higher_than([4 1 2 0]) then + totalSize = seekString(fd, totalSize); // data_mapping + end + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Champ" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekDoubleMatrix(fd, totalSize); // x + totalSize = seekDoubleMatrix(fd, totalSize); // y + totalSize = seekDoubleMatrix(fd, totalSize); // fx + totalSize = seekDoubleMatrix(fd, totalSize); // fy + totalSize = seekBool(fd, totalSize); // line_style + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekBool(fd, totalSize); // colored + totalSize = seekDouble(fd, totalSize); // arrow_size + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Segs" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekDoubleMatrix(fd, totalSize); // data + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekBool(fd, totalSize); // line_style + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekDouble(fd, totalSize); // arrow_size + totalSize = seekIntInt(fd, totalSize); // segs_color + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekBool(fd, totalSize); // mark_style + totalSize = seekBool(fd, totalSize); // mark_size + + if is_higher_than([3 0 0 0]) then + totalSize = seekBool(fd, totalSize); // mark_size_unit + end + + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Grayplot" + totalSize = seekBool(fd, totalSize); // visible + if is_higher_than([3 0 0 0]) then + totalSize = seekDoubleMatrix(fd, totalSize); // x + totalSize = seekDoubleMatrix(fd, totalSize); // y + totalSize = seekDoubleMatrix(fd, totalSize); // z + else + totalSize = seekDoubleMatrix(fd, totalSize); // x,y,z + end + + totalSize = seekString(fd, totalSize); // data_mapping + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Matplot" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekDoubleMatrix(fd, totalSize); // data + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Fec" + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekDoubleMatrix(fd, totalSize); // data + totalSize = seekDoubleMatrix(fd, totalSize); // triangles + totalSize = seekDoubleCount(fd, 2, totalSize); // z_bounds + if is_higher_than( [5 0 3 0] ) then + totalSize = seekDoubleCount(fd, 2, totalSize); // color_range + totalSize = seekDoubleCount(fd, 2, totalSize); // outside_colors + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekInt(fd, totalSize); // foreground + end + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Legend" + if is_higher_than( [5 0 0 0] ) then + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekStringInt(fd, totalSize); // text + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + totalSize = seekInt(fd, totalSize); // font_color + totalSize = seekBool(fd, totalSize); // fractional_font + [totalSize, count] = readBool(fd, totalSize); // legends size + for i = 1 : count + totalSize = seekIntInt(fd, totalSize); // legends + end + + totalSize = seekString(fd, totalSize); // legend_location + totalSize = seekDoubleCount(fd, 2, totalSize); // position + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekShort(fd, totalSize); // thickness + totalSize = seekInt(fd, totalSize); // foreground + totalSize = seekBool(fd, totalSize); // fill_mode + totalSize = seekInt(fd, totalSize); // background + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + else + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekBool(fd, totalSize); // mark_mode + totalSize = seekInt(fd, totalSize); // mark_foreground + totalSize = seekInt(fd, totalSize); // mark_background + totalSize = seekStringInt(fd, totalSize); // text + totalSize = seekInt(fd, totalSize); // foreground + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + if is_higher_than( [4 1 2 0] ) then + totalSize = seekBool(fd, totalSize); // font_size + end + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + end + + case "Text" + totalSize = seekBool(fd, totalSize); // visible + if is_higher_than([4 1 2 0]) then + totalSize = seekStringMatrix(fd, totalSize); + else + totalSize = seekStringInt(fd, totalSize); + end + + [totalSize, count] = readBoolCount(fd, 2, totalSize); // data size + totalSize = seekDoubleCount(fd, prod(count), totalSize); // data + totalSize = seekDoubleCount(fd, 2, totalSize); // text_box + totalSize = seekString(fd, totalSize); // text_box_mode + totalSize = seekInt(fd, totalSize); // foreground + totalSize = seekBool(fd, totalSize); // font_style + totalSize = seekBool(fd, totalSize); // font_size + totalSize = seekDouble(fd, totalSize); // font_angle + + if is_higher_than([3 1 0 1]) then + totalSize = seekBool(fd, totalSize); // box + totalSize = seekBool(fd, totalSize); // line_mode + totalSize = seekBool(fd, totalSize); // fill_mode + totalSize = seekInt(fd, totalSize); // font_foreground + totalSize = seekInt(fd, totalSize); // background + end + + if is_higher_than( [4 1 2 0] ) then + totalSize = seekString(fd, totalSize); // alignment + totalSize = seekBool(fd, totalSize); // fractional_font + end + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + + case "Axis" + if is_higher_than([3 1 0 0]) then + totalSize = seekBool(fd, totalSize); // visible + totalSize = seekBoolInt(fd, totalSize); // tics_direction + totalSize = seekMatrix(fd, totalSize); // xtics_coord + totalSize = seekMatrix(fd, totalSize); // ytics_coord + totalSize = seekInt(fd, totalSize); // tics_color + totalSize = seekBool(fd, totalSize); // tics_segment + totalSize = seekBool(fd, totalSize); // tics_style + totalSize = seekInt(fd, totalSize); // sub_tics + totalSize = seekStringInt(fd, totalSize); // tics_label + totalSize = seekInt(fd, totalSize); // label_font_size + totalSize = seekInt(fd, totalSize); // labels_font_color + if is_higher_than([5 4 0 1]) then + totalSize = seekInt(fd, totalSize); // labels_font_style + end + + if is_higher_than( [4 1 2 0] ) then + totalSize = seekBool(fd, totalSize); // fractional_font + end + + [totalSize, state] = readString(fd, totalSize); // clip_state + if state == "on" then + totalSize = seekDoubleCount(fd, 4, totalSize); //clip_box + end + + totalSize = seekUserdata(fd, totalSize); // Userdata + end + + case "uimenu" + if is_higher_than( [4 1 2 0] ) then + totalSize = seekBool(fd, totalSize); // Enable + totalSize = seekMatrix(fd, totalSize); // Foregroundcolor + totalSize = seekString(fd, totalSize); // Label + totalSize = seekBool(fd, totalSize); // Visible + if is_higher_than([5 4 0 0]) then + totalSize = seekStringInt(fd, totalSize); // Callback + else + totalSize = seekString(fd, totalSize); // Callback + end + totalSize = seekInt(fd, totalSize); // Callback Type + totalSize = seekString(fd, totalSize); // Tag + end + + if is_higher_than( [5 1 2 0] ) then + totalSize = seekBool(fd, totalSize); // Checked + end + + if is_higher_than( [5 1 1 0] ) then + [totalSize, axesCount] = readInt(fd, totalSize); // children + for i = 1 : axesCount + totalSize = getSingleHandleInfo(fd, totalSize); + end + end + + case "uicontextmenu" + [totalSize, axesCount] = readInt(fd, totalSize); // children + for i = 1 : axesCount + totalSize = getSingleHandleInfo(fd, totalSize); + end + case "uicontrol" + if is_higher_than( [4 1 2 0] ) then + totalSize = seekString(fd, totalSize); // Style + totalSize = seekMatrix(fd, totalSize); // BackgroundColor + totalSize = seekBool(fd, totalSize); // Enable + totalSize = seekString(fd, totalSize); // FontAngle + totalSize = seekString(fd, totalSize); // FontName + totalSize = seekDouble(fd, totalSize); // FontSize + totalSize = seekString(fd, totalSize); // FontUnits + totalSize = seekString(fd, totalSize); // FontWeight + totalSize = seekMatrix(fd, totalSize); // ForegroundColor + totalSize = seekString(fd, totalSize); // HorizontalAlignment + totalSize = seekMatrix(fd, totalSize); // ListboxTop + totalSize = seekDouble(fd, totalSize); // Max + totalSize = seekDouble(fd, totalSize); // Min + totalSize = seekMatrix(fd, totalSize); // Position + totalSize = seekString(fd, totalSize); // Relief + totalSize = seekMatrix(fd, totalSize); // SliderStep + totalSize = seekStringMatrix(fd, totalSize); // String + if is_higher_than( [5 2 0 0] ) then // Added in 5.4.0 version + totalSize = seekStringMatrix(fd, totalSize); // TooltipString + end + totalSize = seekString(fd, totalSize); // Units + totalSize = seekMatrix(fd, totalSize); // Value + totalSize = seekString(fd, totalSize); // VerticalAlignment + totalSize = seekBool(fd, totalSize); // Visible + if is_higher_than([5 4 0 0]) then + totalSize = seekStringInt(fd, totalSize); // Callback + else + totalSize = seekString(fd, totalSize); // Callback + end + totalSize = seekInt(fd, totalSize); // Callback Type + totalSize = seekUserdata(fd, totalSize); // Userdata + totalSize = seekString(fd, totalSize); // Tag + end + else + warning("type " +typ+" unhandled"); + end +endfunction +////////////////////////////////////////////////////////// +//read 1 "il" value +function newSize = seekInt(fd, currentSize) + data = mget(1, "il", fd); + //disp("int : " + string(data)); + newSize = currentSize + 4; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function newSize = seekIntCount(fd, len, currentSize) + data = mget(len, "il", fd); + //disp("int : " + string(data)); + newSize = currentSize + 4 * len; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function newSize = seekIntMatrix(fd, currentSize) + offset = mget(1, "c", fd); + data = mget(offset, "il", fd); + //disp("int[] : " + string(data)); + newSize = currentSize + 4 * offset + 1; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function newSize = seekIntInt(fd, currentSize) + offset = mget(1, "il", fd); + data = mget(offset, "il", fd); + //disp("int[] : " + string(data)); + newSize = currentSize + 4 * offset + 4; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function [newSize, data] = readInt(fd, currentSize) + data = mget(1, "il", fd); + //disp("int : " + string(data)); + newSize = currentSize + 4; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function [newSize, data] = readIntCount(fd, len, currentSize) + data = mget(len, "il", fd); + //disp("int : " + string(data)); + newSize = currentSize + 4 * len; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function newSize = seekBool(fd, currentSize) + data = mget(1, "c", fd); + //disp("bool : " + string(data)); + newSize = currentSize + 1; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function [newSize, data] = readBool(fd, currentSize) + data = mget(1, "c", fd); + //disp("bool : " + string(data)); + newSize = currentSize + 1; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function newSize = seekBoolMatrix(fd, currentSize) + offset = mget(1, "c", fd); + data = mget(offset, "c", fd); + //disp("bool : " + string(data)); + newSize = currentSize + offset + 1; +endfunction + +function newSize = seekBoolInt(fd, currentSize) + offset = mget(1, "il", fd); + data = mget(offset, "c", fd); + //disp("bool : " + string(data)); + newSize = currentSize + offset + 4; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function [newSize, data] = readBoolCount(fd, len, currentSize) + data = mget(len, "c", fd); + //disp("bool : " + string(data)); + newSize = currentSize + len; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function newSize = seekDouble(fd, currentSize) + data = mget(1, "dl", fd); + //disp("double : " + string(data)); + newSize = currentSize + 8; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function newSize = seekDoubleCount(fd, len ,currentSize) + data = mget(len, "dl", fd); + //disp("bool : " + string(data)); + newSize = currentSize + len * 8; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function newSize = seekShort(fd, currentSize) + data = mget(1, "sl", fd); + //disp("short : " + string(data)); + newSize = currentSize + 2; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" value +function [newSize, data] = readShort(fd, currentSize) + data = mget(1, "sl", fd); + //disp("short : " + string(data)); + newSize = currentSize + 2; +endfunction + +////////////////////////////////////////////////////////// +//read 2 "c" value +function newSize = seekShortCount(fd, len, currentSize) + data = mget(len, "sl", fd); + //disp("short : " + string(data)); + newSize = currentSize + len * 2; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" size + size * "c" value +function newSize = seekString(fd, currentSize) + offset = mget(1, "c", fd); + data = mget(offset, "c", fd); + //disp("string : " + ascii(data)); + newSize = currentSize + offset + 1; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" size + size * "c" value +function newSize = seekStringInt(fd, currentSize) + offset = mget(1, "il", fd); + data = mget(offset, "c", fd); + //disp("string : " + ascii(data)); + newSize = currentSize + offset + 4; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" size + size * "c" value +function newSize = seekStringCount(fd, len, currentSize) + data = mget(len, "c", fd); + //disp("string : " + ascii(data)); + newSize = currentSize + len; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" size + size * "c" value +function newSize = seekStringMatrix(fd, currentSize) + row = mget(1, "il", fd); + col = mget(1, "il", fd); + for i = 1 : row * col + if is_higher_than([5 4 0 0]) + currentSize = seekStringInt(fd, currentSize); // String + else + currentSize = seekString(fd, currentSize); // String + end + end + newSize = currentSize + 4 * 2; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" size + size * "dl" value +function newSize = seekMatrix(fd, currentSize) + offset = mget(1, "il", fd); + data = mget(offset, "dl", fd); + //disp("double : " + string(data)); + newSize = currentSize + offset * 8 + 4; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" size + size * "dl" value +function newSize = seekMatrixCount(fd, len, currentSize) + data = mget(len, "dl", fd); + //disp("double : " + string(data)); + newSize = currentSize + len * 8; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "c" size + size * "c" value +function newSize = seekDoubleMatrix(fd, currentSize) + row = mget(1, "il", fd); + col = mget(1, "il", fd); + currentSize = seekDoubleCount(fd, row * col, currentSize); + newSize = currentSize + 4 * 2; +endfunction + +////////////////////////////////////////////////////////// +//read user_data +function newSize = seekUserdata(fd, currentSize) + mget(24, "c", fd); + newSize = currentSize + 24; + [typ,dim,vol] = listnextvar(fd); // Userdata + newSize = newSize + vol; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function [newSize, data] = readString(fd, currentSize) + offset = mget(1, "c", fd); + data = ascii(mget(offset, "c", fd)); + //disp("string : " + data); + newSize = currentSize + offset + 1; +endfunction + +////////////////////////////////////////////////////////// +//read 1 "il" value +function [newSize, data] = readStringCount(fd, len, currentSize) + data = ascii(mget(len, "c", fd)); + //disp("string : " + data); + newSize = currentSize + len; +endfunction +////////////////////////////////////////////////////////// +function v=code2var(id) + nsiz=6 + i1=1 + for l=1:nsiz + idl=id(l) + for i=i1:i1+3 + k=int((idl+128)/256) + if k<0 then k=k-1,end + ch=idl-256*k + if ch==40 then + n=i-1 + v=_code2str(str) + return + end + idl=k + str(i)=ch + end + i1=i1+4 + v=_code2str(str) + end +endfunction + +function r=is_higher_than(v) + //check if current version is strictly higher than the given one + r=%f + for k=1:4 + if version(k)>v(k) then r=%t,break,end + if version(k)<v(k) then r=%f,break,end + end +endfunction diff --git a/modules/fileio/macros/%dir_p.bin b/modules/fileio/macros/%dir_p.bin Binary files differnew file mode 100755 index 000000000..1d8386444 --- /dev/null +++ b/modules/fileio/macros/%dir_p.bin diff --git a/modules/fileio/macros/%dir_p.sci b/modules/fileio/macros/%dir_p.sci new file mode 100755 index 000000000..bd5b718d6 --- /dev/null +++ b/modules/fileio/macros/%dir_p.sci @@ -0,0 +1,51 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) DIGITEO - 2011 - Allan CORNET +// +// 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.1-en.txt + +function %dir_p(L) + ll = lines(); + ll = max(ll(1), 20); + name = L.name; + if name == [] then + mprintf("%s \n", "[]"); + return + end + + // If it is a directory, add a trailing "/" + tmp = find(L.isdir); + name(tmp) = name(tmp) + filesep(); + + nc = 6; + l1 = length(name); + while %t + l2 = l1; + n = ceil(size(l1, "*") / nc); + if n*nc > size(name, "*") then + l2(n * nc) = 0; + l1(n * nc) = 0; + end + l = max(matrix(l2, -1, nc), "r"); + if (sum(l) < ll)| (nc == 1) then + break + end + nc = nc - 1; + end + if n * nc > size(name, "*") then + name(n*nc) = ""; + end + name = matrix(name, -1, nc); + txt = emptystr(n, 1); + for k = 1:nc + txt = txt + part(name(:, k), 1 : l(k) + 1); + end + txt = stripblanks(txt); + txt(txt == "") = []; + mprintf("%s \n",txt); +endfunction + diff --git a/modules/fileio/macros/buildmacros.bat b/modules/fileio/macros/buildmacros.bat new file mode 100755 index 000000000..c4e35ec40 --- /dev/null +++ b/modules/fileio/macros/buildmacros.bat @@ -0,0 +1 @@ +@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
\ No newline at end of file diff --git a/modules/fileio/macros/buildmacros.sce b/modules/fileio/macros/buildmacros.sce new file mode 100755 index 000000000..d48ac9b0b --- /dev/null +++ b/modules/fileio/macros/buildmacros.sce @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006 - INRIA - Allan Cornet +// +// 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.1-en.txt + +if (isdef("genlib") == %f) then + exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce"); +end + +genlib("fileiolib","SCI/modules/fileio/macros",%f,%t); diff --git a/modules/fileio/macros/cleanmacros.bat b/modules/fileio/macros/cleanmacros.bat new file mode 100755 index 000000000..5079dfd71 --- /dev/null +++ b/modules/fileio/macros/cleanmacros.bat @@ -0,0 +1,3 @@ +@del *.bin 2>NUL +@del lib 2>NUL +@del names 2>NUL
\ No newline at end of file diff --git a/modules/fileio/macros/dir.bin b/modules/fileio/macros/dir.bin Binary files differnew file mode 100755 index 000000000..c3fc4675c --- /dev/null +++ b/modules/fileio/macros/dir.bin diff --git a/modules/fileio/macros/dir.sci b/modules/fileio/macros/dir.sci new file mode 100755 index 000000000..7d2f4a907 --- /dev/null +++ b/modules/fileio/macros/dir.sci @@ -0,0 +1,66 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// 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.1-en.txt + +function L=dir(str) + + mask = int32(61440); + dirtype = 16384; + + if argn(2) == 1 then + if type(str) <> 10 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"), "dir", 1)); + end + + files = listfiles(str); + basepath = str; + else + files = listfiles(); + basepath = ""; + end + + n = size(files, "*"); + + if n==0 then + files = []; + dt = []; + bytes = []; + isd = []; + else + if getos() == "Windows" then + [tmp,k] = gsort(convstr(files, "l"), "lr", "i") + files = files(k) + else + files = gsort(files, "lr", "i"); + end + + dt = zeros(n, 1); + bytes = zeros(n, 1); + isd(n, 1) = %f; + + for k=1:n + if (basepath == "") then + [x,ierr] = fileinfo(files(k)); + else + [x,ierr] = fileinfo(basepath + "/" + files(k)); + end + + if x == [] & ierr== -1 then + [x,ierr] = fileinfo(files(k)); + end + + if x <> [] then + dt(k) = x(6); + bytes(k) = x(1); + isd(k) = (double(int32(x(2)) & mask) == dirtype); + end + end //for + end //if n==0 + + L = tlist(["dir", "name", "date", "bytes", "isdir"], files, dt, bytes, isd); +endfunction diff --git a/modules/fileio/macros/dirname.bin b/modules/fileio/macros/dirname.bin Binary files differnew file mode 100755 index 000000000..2776d5288 --- /dev/null +++ b/modules/fileio/macros/dirname.bin diff --git a/modules/fileio/macros/dirname.sci b/modules/fileio/macros/dirname.sci new file mode 100755 index 000000000..9206fadb9 --- /dev/null +++ b/modules/fileio/macros/dirname.sci @@ -0,0 +1,37 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ENPC +// +// 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.1-en.txt + +function [files]= dirname(files,flag,flagexpand) + // return the dirnames of files + // if flag == %t files are first converted + // according to getos() == 'Windows'. if flagexpand is also true + // HOME SCI or ~ are also expanded. + // the returned directory names are not terminated by sep + [lhs,rhs]=argn(0) + if rhs <= 1 then flag = %t ; end + if rhs <= 2 then flagexpand = %t ; end + + if flag == %t then + files = pathconvert(files,%f,flagexpand); + end + + sep = filesep(); + + for i=1:size(files,"*") + fname = files(i) + pref_pos = strindex(fname,sep); + if pref_pos <> [] then + fname = part(fname,1:pref_pos($)-1); + else + fname = "."; //emptystr(); + end + files(i)= fname; + end +endfunction + diff --git a/modules/fileio/macros/dispfiles.bin b/modules/fileio/macros/dispfiles.bin Binary files differnew file mode 100755 index 000000000..b894f13ff --- /dev/null +++ b/modules/fileio/macros/dispfiles.bin diff --git a/modules/fileio/macros/dispfiles.sci b/modules/fileio/macros/dispfiles.sci new file mode 100755 index 000000000..9b2322ed0 --- /dev/null +++ b/modules/fileio/macros/dispfiles.sci @@ -0,0 +1,78 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// 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.1-en.txt + +function dispfiles(unit) + [lhs,rhs]=argn() + if rhs==0 then + [units,typ,nams,mod,swap]=file() + else + units=[],typ=[],nams=[],mod=[],swap=[] + for k=1:size(unit,"*") + [uk,tk,nk,mk,sk]=file(unit(k)) + units=[units;uk], + typ=[typ;tk], + nams=[nams;nk], + mod=[mod;mk], + swap=[swap;sk] + end + end + + n=size(units,"*") + info=emptystr(n,1) + for k=1:n + if units(k)==5 then nams(k)="Input",end + if units(k)==6 then nams(k)="Output",end + a=int(mod(k)/100) + b=int((mod(k)-100*a)/10) + c=int((mod(k)-100*a-10*b)) + if typ(k)=="F" then //fortran file + typ(k)="F77" + select c + case 0 then + info(k)=info(k)+"new " + case 1 then + info(k)=info(k)+"old " + case 2 then + info(k)=info(k)+"scratch " + case 3 then + info(k)=info(k)+"unknown " + end + if a==0 then + info(k)=info(k)+"formatted " + else + info(k)=info(k)+"unformatted " + end + if b==0 then + //info(k)=info(k)+' ' + else + info(k)=info(k)+"direct " + end + else //C file + select a + case 1 then + info(k)=info(k)+"r " + case 2 then + info(k)=info(k)+"w " + case 3 then + info(k)=info(k)+"a " + end + if b==1 then info(k)=info(k)+"+ ",end + if c==1 then info(k)=info(k)+"b ";end + if swap(k)<>0 then info(k)=info(k)+"swap=on";end + end + end + tab=["File name" "Unit" "Type" "Options"; + nams(:) string(units(:)) typ(:) info] + t=emptystr(n+1,1)+"|" + for k=1:size(tab,2) + t=t+part(tab(:,k),1:max(length(tab(:,k))))+"|" + end + t=[t(1);"|"+part("-",ones(1,max(length(t))-2))+"|";t(2:$)] + write(%io(2),t,"(a)") +endfunction diff --git a/modules/fileio/macros/fullfile.bin b/modules/fileio/macros/fullfile.bin Binary files differnew file mode 100755 index 000000000..f72d560b5 --- /dev/null +++ b/modules/fileio/macros/fullfile.bin diff --git a/modules/fileio/macros/fullfile.sci b/modules/fileio/macros/fullfile.sci new file mode 100755 index 000000000..6462377a4 --- /dev/null +++ b/modules/fileio/macros/fullfile.sci @@ -0,0 +1,69 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA - Vincent COUVERT +// Copyright (C) DIGITEO - 2010-2012 - Allan CORNET +// +// 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.1-en.txt + +function f = fullfile(varargin) + + // Build a full filename from parts + + if lstsize(varargin) < 1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fullfile",1)); + end + + fs = ["/" "\"]; + f = varargin(1); + + if ~isempty(f) then + if type(f) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a string expected.\n"), "fullfile", 1)); + end + + if size(f,"*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a string expected.\n"), "fullfile", 1)); + end + f = stripblanks(f); + end + + nbParameters = lstsize(varargin) + for k = 2 : nbParameters + arg = varargin(k); + if isempty(f) | isempty(arg) + if ~isempty(arg) then + if type(arg) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a string expected.\n"), "fullfile", k)); + end + + if (size(arg,"*") <> 1) & (k <> nbParameters) then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a string expected.\n"), "fullfile", k)); + end + end + f = f + arg; + else + + if type(arg) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a string expected.\n"), "fullfile", k)); + end + + if (size(arg,"*") <> 1) & (k <> nbParameters) then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a string expected.\n"), "fullfile", k)); + end + + if or(part(f, length(f)) == fs) & or(part(arg, 1) == fs) + f = f + stripblanks(part(arg, 2:length(arg))); + elseif or(part(f, length(f))==fs) | or(part(arg, 1)==fs) + f = f + stripblanks(arg); + else + f = f + pathconvert("/") + stripblanks(arg); + end + end + end + + f = pathconvert(f, %f, %f); + +endfunction diff --git a/modules/fileio/macros/get_file_path.bin b/modules/fileio/macros/get_file_path.bin Binary files differnew file mode 100755 index 000000000..dde72b7f2 --- /dev/null +++ b/modules/fileio/macros/get_file_path.bin diff --git a/modules/fileio/macros/get_file_path.sci b/modules/fileio/macros/get_file_path.sci new file mode 100755 index 000000000..a8d1a9f89 --- /dev/null +++ b/modules/fileio/macros/get_file_path.sci @@ -0,0 +1,24 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// 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.1-en.txt + +function path = get_file_path(name) + //------------------------------- + // returns loader full path + path ="./"; + [units,typs,nams]=file(); + clear units typs + for k=size(nams,"*"):-1:1 + l=strindex(nams(k),name); + if l<>[] then + path=part(nams(k),1:l($)-1); + break + end + end + if path == "" then path = pwd() ; end +endfunction diff --git a/modules/fileio/macros/is_absolute_path.bin b/modules/fileio/macros/is_absolute_path.bin Binary files differnew file mode 100755 index 000000000..86b188b25 --- /dev/null +++ b/modules/fileio/macros/is_absolute_path.bin diff --git a/modules/fileio/macros/is_absolute_path.sci b/modules/fileio/macros/is_absolute_path.sci new file mode 100755 index 000000000..8ef4a5978 --- /dev/null +++ b/modules/fileio/macros/is_absolute_path.sci @@ -0,0 +1,45 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007 - INRIA - Pierre MARECHAL +// +// 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.1-en.txt + +// ============================================================================= +// Date : 28/11/2007 +// +// Determines if the path is an absolute name. +// ============================================================================= + +function status = is_absolute_path(pathname) + + status = %F; + + // Strips leading and trailing blanks and tabs of the path + pathname = stripblanks(pathname,%T); + + if getos() == "Windows" then + + // Windows Case + + if isletter(part(pathname,1)) & (part(pathname,2) == ":") then + status = %T; + end + + if (part(pathname,[1:7])=="file:") .. + | (part(pathname,[1:2])=="\\") .. + | (part(pathname,[1:2])=="//") then + status = %T; + + end + + else + + // Unix case + + status = (part(pathname,1)=="/") | (part(pathname,1)=="~"); + end + +endfunction diff --git a/modules/fileio/macros/lib b/modules/fileio/macros/lib Binary files differnew file mode 100755 index 000000000..c1caa9f1f --- /dev/null +++ b/modules/fileio/macros/lib diff --git a/modules/fileio/macros/listfiles.bin b/modules/fileio/macros/listfiles.bin Binary files differnew file mode 100755 index 000000000..7cb196be6 --- /dev/null +++ b/modules/fileio/macros/listfiles.bin diff --git a/modules/fileio/macros/listfiles.sci b/modules/fileio/macros/listfiles.sci new file mode 100755 index 000000000..1c563a400 --- /dev/null +++ b/modules/fileio/macros/listfiles.sci @@ -0,0 +1,108 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007 - INRIA - Allan CORNET +// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS +// +// 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.1-en.txt + + +function files= listfiles(paths,flag,flagexpand) + + // list the files in a set of directories + // files= listfiles(paths [,flag,flagexpand]) + // paths : a string matrix giving a set of pathnames (eventually ended by a pattern built with * ) + // flag,flagexpand : boolean optional parameters. (default value %t ). + // files : a string matrix + + [lhs,rhs]=argn(0) + if rhs < 1 then paths="./" ; end + if rhs <= 1 then flag = %t ; end + if rhs <= 2 then flagexpand = %t ; end + files=[]; + + // Stripblanks paths + paths = stripblanks(paths); + + // list files of the current directory + paths(find(paths=="")) = "./"; + + if flag == %t then + paths = pathconvert(paths,%f,flagexpand); + end + + // list files of the root directory + if getos() <> "Windows" then + paths(find(paths=="")) = "/"; + end + + DIR_SEPARATOR=filesep(); + + bMulti = %f; + if size(paths,"*") > 1 then + bMulti = %t; + end + + for i=1:size(paths,"*") // Loop on the file/path list + [path,fname,extension]=fileparts(paths(i)); // Retrieve the information + // about the file + if isdir(paths(i)) then // It is a directory then returns all the file in the dir + path = paths(i) + filesep(); + fname="*"; + if bMulti then + if getos() == "Windows" // Don't want this case under Linux/Unix + // Windows will return the file toto even if you provided toto.* + extension=".*"; + end + else + extension=""; + end + else + // It is a file + if path == "" then path="./",end; + if getos() == "Windows" // Don't want this case under Linux/Unix + // Windows will return the file toto even if you provided toto.* + if extension == "" then extension=".*",end; + end + + if fname == "" then fname="*",end; + end + + filesi=findfiles(path,fname+extension); + + if filesi<>[] then + filesi=filesi($:-1:1); + // prepend with the path, if required + // when listing a full directory, path is not prepended + dirs=paths(i); + if part(dirs,length(dirs))<>DIR_SEPARATOR then + if isdir(dirs) then + if bMulti then //yes + with_dir=%t; + dirs = dirs + filesep(); + else + with_dir=%f; + end + else //no + k=strindex(dirs,DIR_SEPARATOR); + if k==[] then + with_dir=%f; + else + dirs=part(dirs,1:k($)); + with_dir=%t; + end + end + else + with_dir=%f; + end // if part(dirs,length(dirs) ... + + if with_dir then + filesi = dirs+filesi; + end + + files=[files;filesi]; + end // if filesi<>[] then + end // for i=1:size(paths,'*') +endfunction diff --git a/modules/fileio/macros/listvarinfile.bin b/modules/fileio/macros/listvarinfile.bin Binary files differnew file mode 100755 index 000000000..0d76c95ae --- /dev/null +++ b/modules/fileio/macros/listvarinfile.bin diff --git a/modules/fileio/macros/listvarinfile.sci b/modules/fileio/macros/listvarinfile.sci new file mode 100755 index 000000000..a0021ae74 --- /dev/null +++ b/modules/fileio/macros/listvarinfile.sci @@ -0,0 +1,42 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Antoine ELIAS +// +// 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.1-en.txt + + +function varargout = listvarinfile(filename) + + [lhs, rhs] = argn(); + if rhs <> 1 then + error(999, msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "listvarinfile", 1)); + end + + if typeof(filename) <> "string" | size(filename, "*") <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "listvarinfile", 1)); + end + + if isfile(filename) & is_hdf5_file(filename) then + listvarFunction = listvar_in_hdf5; + else + listvarFunction = %_listvarinfile; + end + + //check output argument count + if lhs == 1 then + a = listvarFunction(filename); + varargout = list(a); + elseif lhs == 2 then + [a,b] = listvarFunction(filename); + varargout = list(a,b); + elseif lhs == 3 then + [a,b,c] = listvarFunction(filename); + varargout = list(a,b,c); + elseif lhs == 4 then + [a,b,c,d] = listvarFunction(filename); + varargout = list(a,b,c,d); + end +endfunction diff --git a/modules/fileio/macros/ls.bin b/modules/fileio/macros/ls.bin Binary files differnew file mode 100755 index 000000000..b97224293 --- /dev/null +++ b/modules/fileio/macros/ls.bin diff --git a/modules/fileio/macros/ls.sci b/modules/fileio/macros/ls.sci new file mode 100755 index 000000000..7d6dcdfc8 --- /dev/null +++ b/modules/fileio/macros/ls.sci @@ -0,0 +1,39 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA - Serge STEER +// Copyright (C) INRIA - Allan CORNET +// Copyright (C) INRIA - Sylvestre LEDRU +// +// 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.1-en.txt + +function files=ls(varargin) + + // interface to ls + + opts=[]; + + if size(varargin)==0 then + path = "./"; + else + path = varargin(1); + if type(path) <> 10 then + error(999,msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"ls",1)); + end + for k=2:size(varargin) + opts = [opts varargin(k)]; + end + end + + if size(opts,"*")<>0 then + warning(msprintf(gettext("%s: Options ignored.\n"),"ls")); + end + + if or(path=="PWD") then path=evstr(path),end + + // dir returns names without the dirname + files = listfiles(path); + +endfunction diff --git a/modules/fileio/macros/mdelete.bin b/modules/fileio/macros/mdelete.bin Binary files differnew file mode 100755 index 000000000..da0315ffc --- /dev/null +++ b/modules/fileio/macros/mdelete.bin diff --git a/modules/fileio/macros/mdelete.sci b/modules/fileio/macros/mdelete.sci new file mode 100755 index 000000000..e5dafd547 --- /dev/null +++ b/modules/fileio/macros/mdelete.sci @@ -0,0 +1,61 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA - Vincent COUVERT +// Copyright (C) INRIA - Pierre MARECHAL +// +// 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.1-en.txt + +function mdelete(filename) + + // Scilab Project - V. Couvert + // Delete a file given by filename (or a set of files if meta-characters used in filename) + + // Modified by Pierre MARECHAL + // Scilab Team + // Date : 2006-06-29 + // Fix the bug2041 + + // Date : 2007-01-16 + // Fix the bug2288 (Thanks to M. Dubois, http://dubois.ensae.net ) + + rhs = argn(2); + if rhs <> 1 then + error(77); + end + + if type(filename) <> 10 | size(filename,"*") <> 1 then + error(msprintf(gettext("%s: Wrong type for input argument: String expected.\n"),"mdelete")); + end + + // Handle file path + if getos() == "Windows" then + filename = strsubst(filename,filesep(),"/"); + end + + // File path + k = strindex(filename,"/"); + + if k == [] then + file_path = "./"; + else + file_path = part(filename,1:k($)); + filename = part(filename,k($)+1:length(filename)); + end + + if getos() == "Windows" then + fullfilename = strsubst(file_path+filename,"/","\"); + lst_files = listfiles(fullfilename); + else + lst_files = listfiles(file_path+filename); + end + + if lst_files<>[] then + for i=1:size(lst_files,"*") + deletefile(lst_files(i)); + end + end + +endfunction diff --git a/modules/fileio/macros/mkdir.bin b/modules/fileio/macros/mkdir.bin Binary files differnew file mode 100755 index 000000000..c899ea628 --- /dev/null +++ b/modules/fileio/macros/mkdir.bin diff --git a/modules/fileio/macros/mkdir.sci b/modules/fileio/macros/mkdir.sci new file mode 100755 index 000000000..a1d60929c --- /dev/null +++ b/modules/fileio/macros/mkdir.sci @@ -0,0 +1,141 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007 - INRIA - Allan CORNET +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// 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.1-en.txt + +function [status, msg]=mkdir(varargin) + // mkdir Make a directory + //------------------------------------------------------------------------ + + lhs = argn(1); + rhs = argn(2); + + DirName = ""; + NewDirName = ""; + status = 0 ; + msg = ""; + + select rhs + + case 0 + error(msprintf(gettext("%s: Wrong number of input argument(s).\n"), "mkdir")); + break + + case 1 + NewDirName = varargin(1); + if type(NewDirName) <> 10 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "mkdir", 1)); + end + + if size(NewDirName, "*") <> 1 then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "mkdir", 1)); + end + + NewDirName = stripblanks(NewDirName, %T); + if is_absolute_path(NewDirName) then + NewDirectory = NewDirName; + else + NewDirectory = fullfile(pwd(),NewDirName); + end + break + + case 2 + DirName = varargin(1); + if type(DirName) <> 10 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "mkdir", 1)); + end + + if size(DirName, "*") <> 1 then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "mkdir", 1)); + end + + NewDirName = varargin(2); + if type(NewDirName) <> 10 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "mkdir", 2)); + end + + if size(NewDirName, "*") <> 1 then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "mkdir", 2)); + end + + NewDirName = stripblanks(NewDirName, %T); + DirName = stripblanks(DirName, %T); + NewDirectory = fullfile(DirName, NewDirName); + break + + else + error(msprintf(gettext("%s: Wrong number of input argument(s).\n"), "mkdir")); + end + + NewDirectory = fullpath(NewDirectory); + + if ~isdir(NewDirectory) & ~isfile(NewDirectory) then + // The directory does not exist + status = 1; + else + // The directory or file exists + if isfile(NewDirectory) then + // it is a file + status = -2; + else + // it is a directory + status = 2; + end + end + + select status + + case 0 + break + + case 1 + bAddFirstDirSep = %f; + subdirs = strsplit(NewDirectory, ["/" "\"]); + if subdirs(1) == "" then + subdirs(1) = []; + bAddFirstDirSep = %t; + end + for i = 1:size(subdirs, "*") + currentsubdir = strcat(subdirs(1:i), filesep()); + if bAddFirstDirSep then + currentsubdir = filesep() + currentsubdir; + end + if ~isfile(currentsubdir) & ~isdir(currentsubdir) then + status = createdir(currentsubdir); + if ~status then + break + end + end + end + + if ~isdir(NewDirectory) & ~isfile(NewDirectory) then + status = createdir(NewDirectory); + end + + if (~status) then + msg = msprintf(gettext("%s: An error occurred: %s\n"),"mkdir",gettext("Impossible to create directory ")) + NewDirectory; + status = 0; + else + msg = ""; + status = 1; + end + break + + case 2 + msg = msprintf(gettext("%s: An error occurred: %s\n"),"mkdir",gettext("This directory already exists in ")) + NewDirectory; + break + + case -2 + msg = msprintf(gettext("%s: An error occurred: %s\n"),"mkdir",gettext("A file with the same name already exists in ")) + DirName; + break + + else + msg = msprintf(gettext("%s: An error occurred: %s\n"),"mkdir",gettext("Impossible to create directory ")) + NewDirectory; + end + +endfunction diff --git a/modules/fileio/macros/names b/modules/fileio/macros/names new file mode 100755 index 000000000..14e52e213 --- /dev/null +++ b/modules/fileio/macros/names @@ -0,0 +1,15 @@ +%_listvarinfile +%dir_p +dir +dirname +dispfiles +fullfile +get_file_path +is_absolute_path +listfiles +listvarinfile +ls +mdelete +mkdir +rmdir +scanf diff --git a/modules/fileio/macros/rmdir.bin b/modules/fileio/macros/rmdir.bin Binary files differnew file mode 100755 index 000000000..29e52be1f --- /dev/null +++ b/modules/fileio/macros/rmdir.bin diff --git a/modules/fileio/macros/rmdir.sci b/modules/fileio/macros/rmdir.sci new file mode 100755 index 000000000..8204ab3e8 --- /dev/null +++ b/modules/fileio/macros/rmdir.sci @@ -0,0 +1,71 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007 - INRIA - Allan CORNET +// +// 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.1-en.txt + +// rmdir remove a directory +function [status,msg]=rmdir(varargin) + lhs=argn(1); + rhs=argn(2); + + DirName = ""; + status = 0; + msg = ""; + SubDirMode = %F; + + select rhs + case 0 + error(msprintf(gettext("%s: Wrong number of input argument(s).\n"),"rmdir")); + break + case 1 + DirName = varargin(1); + break + case 2 + DirName = varargin(1) ; + SubDir = convstr(varargin(2),"u"); + if (SubDir == "S") then + SubDirMode = %T; + else + error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be ''%s''.\n"),"rmdir",2,"s")); + end + break + else + error(msprintf(gettext("%s: Wrong number of input argument(s).\n"),"rmdir")); + end + + if ~SubDirMode then + if findfiles(DirName)<>[] then + status = 0 + msg = gettext("Error: The directory is not empty.") + else + [status,msg] = hidden_rmdir(DirName); + end + else + [status,msg] = hidden_rmdir(DirName); + end +endfunction +//------------------------------------------------------------------------ +function [status,msg]=hidden_rmdir(DirName) + status = 0; + msg = ""; + + if isdir(DirName) then + bOK = removedir(DirName); + if bOK then + msg = ""; + status = 1; + else + msg = msprintf(gettext("%s: An error occurred: %s\n"),"rmdir", gettext("Undefined")); + status = 0; + end + else + msg = msprintf(gettext("%s: An error occurred: %s\n"),"rmdir", gettext("The system cannot find the file specified.")); + status = 0; + end + +endfunction +//------------------------------------------------------------------------ diff --git a/modules/fileio/macros/scanf.bin b/modules/fileio/macros/scanf.bin Binary files differnew file mode 100755 index 000000000..b46897b5f --- /dev/null +++ b/modules/fileio/macros/scanf.bin diff --git a/modules/fileio/macros/scanf.sci b/modules/fileio/macros/scanf.sci new file mode 100755 index 000000000..f9abef910 --- /dev/null +++ b/modules/fileio/macros/scanf.sci @@ -0,0 +1,20 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// 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.1-en.txt + +function [v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,.. + v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30]= scanf(frmt) + // scanf - Emulator of C language scanf + + //! + [lhs,rhs]=argn(0) + v="v" + args=strcat(v(ones(lhs,1))+string(1:lhs)',",") + buf=read(%io(1),1,1,"(a)") + execstr("["+args+"]=msscanf(buf,frmt)") +endfunction |