1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Copyright (C) 2007 - INRIA - Allan CORNET 3// 4// Copyright (C) 2012 - 2016 - Scilab Enterprises 5// 6// This file is hereby licensed under the terms of the GNU GPL v2.0, 7// pursuant to article 5.3.4 of the CeCILL v.2.1. 8// This file was originally licensed under the terms of the CeCILL v2.1, 9// and continues to be available under such terms. 10// For more information, see the COPYING file which you should have received 11// along with this program. 12 13// rmdir remove a directory 14function [status,msg]=rmdir(varargin) 15 lhs=argn(1); 16 rhs=argn(2); 17 18 DirName = ""; 19 status = 0; 20 msg = ""; 21 SubDirMode = %F; 22 23 select rhs 24 case 0 25 error(msprintf(gettext("%s: Wrong number of input argument(s).\n"),"rmdir")); 26 break 27 case 1 28 DirName = varargin(1); 29 break 30 case 2 31 DirName = varargin(1) ; 32 SubDir = convstr(varargin(2),"u"); 33 if (SubDir == "S") then 34 SubDirMode = %T; 35 else 36 error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be ''%s''.\n"),"rmdir",2,"s")); 37 end 38 break 39 else 40 error(msprintf(gettext("%s: Wrong number of input argument(s).\n"),"rmdir")); 41 end 42 43 if ~SubDirMode then 44 if findfiles(DirName)<>[] then 45 status = 0 46 msg = gettext("Error: The directory is not empty.") 47 else 48 [status,msg] = hidden_rmdir(DirName); 49 end 50 else 51 [status,msg] = hidden_rmdir(DirName); 52 end 53endfunction 54//------------------------------------------------------------------------ 55function [status,msg]=hidden_rmdir(DirName) 56 status = 0; 57 msg = ""; 58 59 if isdir(DirName) then 60 bOK = removedir(DirName); 61 if bOK then 62 msg = ""; 63 status = 1; 64 else 65 msg = msprintf(gettext("%s: An error occurred: %s\n"),"rmdir", gettext("Undefined")); 66 status = 0; 67 end 68 else 69 msg = msprintf(gettext("%s: An error occurred: %s\n"),"rmdir", gettext("The system cannot find the file specified.")); 70 status = 0; 71 end 72 73endfunction 74//------------------------------------------------------------------------ 75