1// ============================================================================= 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3// Copyright (C) 2009 - DIGITEO 4// Copyright (C) 2016 - Scilab Enterprises - Clement David 5// 6// This file is distributed under the same license as the Scilab package. 7// ============================================================================= 8 9// <-- CLI SHELL MODE --> 10 11 12filename = pathconvert(TMPDIR+"/filetodelete_1.txt",%F); 13filename2 = pathconvert(TMPDIR+"/filetodelete_2.txt",%F); 14 15// Regular use 16fd=mopen ( filename , "w" ); 17mclose(fd); 18computed = deletefile ( filename ); 19if computed <> %t then pause,end 20 21// Wrong use then correct use 22// NOTE: windows file API failed to remove an opened file 23if getos() == "Windows" then 24 fd=mopen ( filename , "w" ); 25 computed = deletefile ( filename ); 26 if computed <> %f then pause,end 27 mclose(fd); 28 computed = deletefile ( filename ); 29 if computed <> %t then pause,end 30end 31 32// try to delete a non-existing file 33filename = pathconvert(TMPDIR+"/filetodelete_2.txt",%F); 34computed = deletefile ( filename ); 35if computed <> %f then pause,end 36 37// try to delete two files 38fd=mopen ( filename , "w" ); 39mclose(fd); 40fd=mopen ( filename2 , "w" ); 41mclose(fd); 42computed = deletefile ( [filename filename2] ); 43if computed <> [%t %t] then pause,end 44 45// try to delete twice the same file 46fd=mopen ( filename , "w" ); 47mclose(fd); 48computed = deletefile ( [filename filename] ); 49if computed <> [%t %f] then pause,end 50 51// try to delete the same file on a matrix 52fd=mopen ( filename , "w" ); 53mclose(fd); 54computed = deletefile ( [filename2 filename ; filename2 filename]); 55if computed <> [%f %t ; %f %f] then pause,end 56 57