I have MATLAB running on a networked filesystem (Linux, NFS). When I do 'cp -p' at the Linux command line to copy with permissions preserved, the copy is made but I get a warning
cp: preserving permissions for `targetfilenamehere': Operation not supported.
OK, I can ignore my OS complaints. Now, the real problem is that this messes up MATLAB. The copyfile command used inside MATLAB generates the same error, while it actually does copy the file.
The error causes copyfile to 'fail' by throwing an error.
>> copyfile gunk3.txt gunk4.txt ??? Error using ==> copyfile cp: preserving permissions for `/cise/homes/davis/gunk4.txt': Operation not supported
There appears to be no way to tell copyfile that this 'error' is not really an error.
There is an ugly workaround (see below), but this seems very ad hoc and fragile. What if the error message changes, for example? This code, below, is not very portable, yet I must rely on it in code that must be portable and usable for end-users on many OS's and many MATLAB versions. Not a trivial problem.
is there a more elegant solution? A better solution would be for 'copyfile' to issue a warning about permissions, not an error. But that requires a change to MATLAB itself.
function cpfile (src, dst)
if (length (dir (src)) == 0)
error ('File does not exist') ;
copyfile (src, dst) ;
if (isempty (strfind (ME.message, 'Operation not supported')))
rethrow (ME) ;