<< helptbx_iscontentupdte helptbx

helptbx >> helptbx > helptbx_updtifneeded

helptbx_updtifneeded

Update a file if this is needed.

Calling Sequence

b = helptbx_updtifneeded ( content , filename )

Parameters

content :

a 1-by-1 matrix of strings, the new content

filename :

a 1-by-1 matrix of strings, the file to be checked.

b :

a 1-by-1 matrix of booleans

Description

Returns true if the filename is up-to-date, that is, if the file was not changed. Returns false if the file was changed.

The file is to be updated according to the rules of the helptbx_iscontentupdte function. Generates an error if the file was to be changed, but that was not possible.

Examples

// Create a sample file.
content = "Coucou!";
filename = fullfile(TMPDIR,"test.txt");
// Update the file.
b = helptbx_updtifneeded ( content , filename ) // Expected=%f
// See the content of the file.
content2 = mgetl ( filename )
and(content==content2) // Expected=%t
// No update is necessary now.
b = helptbx_updtifneeded ( content , filename ) // Expected=%t
// Change the content
content = "Hello!";
b = helptbx_updtifneeded ( content , filename ) // Expected=%f
// See the content of the file.
content2 = mgetl ( filename )
and(content==content2) // Expected=%t
// No update is necessary now.
b = helptbx_updtifneeded ( content , filename ) // Expected=%t
// Delete the file
mdelete(filename);

Authors


Report an issue
<< helptbx_iscontentupdte helptbx