copyfile permissions
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)
% cpfile: copy the src file to the filename dst, overwriting dst if it exists
rmfile (dst)
if (length (dir (src)) == 0) %#ok
error ('File does not exist') ;
end
try
copyfile (src, dst) ;
catch ME
% ignore errors of the form "cp: preserving permissions: ...
% Operation not supported". rethrow all other errors.
if (isempty (strfind (ME.message, 'Operation not supported')))
rethrow (ME) ;
end
end
0 comentarios
Respuestas (1)
Walter Roberson
el 2 de Nov. de 2011
Please see the previous discussion at http://www.mathworks.com/matlabcentral/answers/8201-couldn-t-run-codegen-under-matlab
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!