summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-05-10 05:05:45 +0000
committerErik Andersen <andersen@codepoet.org>2000-05-10 05:05:45 +0000
commit59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c (patch)
tree8db9c40b68387c1017007f5265e45c2a66ccfb0d /utility.c
parentac130e1dca289c431c43b6efee4b3d9f2b367c87 (diff)
downloadbusybox-w32-59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c.tar.gz
busybox-w32-59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c.tar.bz2
busybox-w32-59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c.zip
* cp -fa now works as expected for symlinks (it didn't before)
* zcat works again (wasn't working since option parsing was broken) * more doc updates/more support for BB_FEATURE_SIMPLE_HELP -Erik
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/utility.c b/utility.c
index c8442f1ba..5899fe954 100644
--- a/utility.c
+++ b/utility.c
@@ -234,15 +234,14 @@ int isDirectory(const char *fileName, const int followLinks, struct stat *statBu
234 234
235#if defined (BB_CP_MV) 235#if defined (BB_CP_MV)
236/* 236/*
237 * Copy one file to another, while possibly preserving its modes, times, 237 * Copy one file to another, while possibly preserving its modes, times, and
238 * and modes. Returns TRUE if successful, or FALSE on a failure with an 238 * modes. Returns TRUE if successful, or FALSE on a failure with an error
239 * error message output. (Failure is not indicated if the attributes cannot 239 * message output. (Failure is not indicated if attributes cannot be set.)
240 * be set.) 240 * -Erik Andersen
241 * -Erik Andersen
242 */ 241 */
243int 242int
244copyFile(const char *srcName, const char *destName, 243copyFile(const char *srcName, const char *destName,
245 int setModes, int followLinks) 244 int setModes, int followLinks, int forceFlag)
246{ 245{
247 int rfd; 246 int rfd;
248 int wfd; 247 int wfd;
@@ -268,7 +267,8 @@ copyFile(const char *srcName, const char *destName,
268 else 267 else
269 status = lstat(destName, &dstStatBuf); 268 status = lstat(destName, &dstStatBuf);
270 269
271 if (status < 0) { 270 if (status < 0 || forceFlag==TRUE) {
271 unlink(destName);
272 dstStatBuf.st_ino = -1; 272 dstStatBuf.st_ino = -1;
273 dstStatBuf.st_dev = -1; 273 dstStatBuf.st_dev = -1;
274 } 274 }
@@ -306,10 +306,8 @@ copyFile(const char *srcName, const char *destName,
306 } 306 }
307#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) 307#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
308 if (setModes == TRUE) { 308 if (setModes == TRUE) {
309 if (lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid) < 0) { 309 /* Try to set owner, but fail silently like GNU cp */
310 perror(destName); 310 lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
311 return FALSE;
312 }
313 } 311 }
314#endif 312#endif
315 return TRUE; 313 return TRUE;