diff options
author | Chris Johns <chrisj@rtems.org> | 2008-08-07 02:23:11 +0000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2008-08-07 02:23:11 +0000 |
commit | 8192e4ff6139a599d38e7df8a4d27f12144cfad8 (patch) | |
tree | cf02a8c71d66583a746bffb40af086108dcde879 /cpukit/libcsupport/src/_rename_r.c | |
parent | 2008-08-06 Chris Johns <chrisj@rtems.org> (diff) | |
download | rtems-8192e4ff6139a599d38e7df8a4d27f12144cfad8.tar.bz2 |
2008-08-07 Chris Johns <chrisj@rtems.org>
* libcsupport/src/_rename_r.c: Fixed return code bug. Add a check
to see if the 'to' path was a directory and removed the directory.
* libmisc/Makefile.am, libmisc/shell/shellconfig.h: Added the mv command.
* libmisc/shell/main_mv.c, libmisc/shell/pathnames-mv.h: New.
Diffstat (limited to 'cpukit/libcsupport/src/_rename_r.c')
-rw-r--r-- | cpukit/libcsupport/src/_rename_r.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/_rename_r.c b/cpukit/libcsupport/src/_rename_r.c index b0a636f468..1395099b5e 100644 --- a/cpukit/libcsupport/src/_rename_r.c +++ b/cpukit/libcsupport/src/_rename_r.c @@ -25,16 +25,22 @@ #include <rtems/libio_.h> #include <rtems/seterr.h> +#include <sys/stat.h> + int _rename_r( struct _reent *ptr, const char *old, const char *new ) { + struct stat sb; int s; + s = stat( old, &sb); + if ( s < 0 ) + return s; s = link( old, new ); - if ( !s ) + if ( s < 0 ) return s; - return unlink( old ); + return S_ISDIR(sb.st_mode) ? rmdir( old ) : unlink( old ); } |