aboutsummaryrefslogtreecommitdiff
path: root/libbb/copy_file.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-22 22:13:17 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-23 04:44:33 +1000
commit251687097b60bad7a88de930576b7177f34fa975 (patch)
tree79e04bf5487a27e1915f29778f6bff577a3a223b /libbb/copy_file.c
parentd791e72dc28009f36da26703fc007e40cfa79414 (diff)
downloadbusybox-w32-251687097b60bad7a88de930576b7177f34fa975.tar.gz
busybox-w32-251687097b60bad7a88de930576b7177f34fa975.tar.bz2
busybox-w32-251687097b60bad7a88de930576b7177f34fa975.zip
adapt it to be buildable
Diffstat (limited to 'libbb/copy_file.c')
-rw-r--r--libbb/copy_file.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index a6cfe122d..cf1c756d5 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -83,12 +83,14 @@ int copy_file(const char *source, const char *dest, int flags)
83 return -1; 83 return -1;
84 } 84 }
85 } else { 85 } else {
86#ifndef __MINGW32__
86 if (source_stat.st_dev == dest_stat.st_dev 87 if (source_stat.st_dev == dest_stat.st_dev
87 && source_stat.st_ino == dest_stat.st_ino 88 && source_stat.st_ino == dest_stat.st_ino
88 ) { 89 ) {
89 bb_error_msg("'%s' and '%s' are the same file", source, dest); 90 bb_error_msg("'%s' and '%s' are the same file", source, dest);
90 return -1; 91 return -1;
91 } 92 }
93#endif
92 dest_exists = 1; 94 dest_exists = 1;
93 } 95 }
94 96
@@ -178,6 +180,7 @@ int copy_file(const char *source, const char *dest, int flags)
178 // Hmm... maybe 180 // Hmm... maybe
179 // if (DEREF && MAKE_SOFTLINK) source = realpath(source) ? 181 // if (DEREF && MAKE_SOFTLINK) source = realpath(source) ?
180 // (but realpath returns NULL on dangling symlinks...) 182 // (but realpath returns NULL on dangling symlinks...)
183#ifndef __MINGW32__
181 lf = (flags & FILEUTILS_MAKE_SOFTLINK) ? symlink : link; 184 lf = (flags & FILEUTILS_MAKE_SOFTLINK) ? symlink : link;
182 if (lf(source, dest) < 0) { 185 if (lf(source, dest) < 0) {
183 ovr = ask_and_unlink(dest, flags); 186 ovr = ask_and_unlink(dest, flags);
@@ -188,6 +191,7 @@ int copy_file(const char *source, const char *dest, int flags)
188 return -1; 191 return -1;
189 } 192 }
190 } 193 }
194#endif
191 return 0; 195 return 0;
192 196
193 } else if (S_ISREG(source_stat.st_mode) 197 } else if (S_ISREG(source_stat.st_mode)
@@ -196,6 +200,7 @@ int copy_file(const char *source, const char *dest, int flags)
196 ) { 200 ) {
197 int src_fd; 201 int src_fd;
198 int dst_fd; 202 int dst_fd;
203#ifndef __MINGW32__
199 if (ENABLE_FEATURE_PRESERVE_HARDLINKS) { 204 if (ENABLE_FEATURE_PRESERVE_HARDLINKS) {
200 char *link_name; 205 char *link_name;
201 206
@@ -216,6 +221,7 @@ int copy_file(const char *source, const char *dest, int flags)
216 } 221 }
217 add_to_ino_dev_hashtable(&source_stat, dest); 222 add_to_ino_dev_hashtable(&source_stat, dest);
218 } 223 }
224#endif
219 225
220 src_fd = open_or_warn(source, O_RDONLY); 226 src_fd = open_or_warn(source, O_RDONLY);
221 if (src_fd < 0) { 227 if (src_fd < 0) {
@@ -274,6 +280,7 @@ int copy_file(const char *source, const char *dest, int flags)
274 status = -1; 280 status = -1;
275 } 281 }
276 282
283#ifndef __MINGW32__
277 } else if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode) 284 } else if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode)
278 || S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode) 285 || S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode)
279 || S_ISLNK(source_stat.st_mode) 286 || S_ISLNK(source_stat.st_mode)
@@ -312,6 +319,7 @@ int copy_file(const char *source, const char *dest, int flags)
312 return -1; 319 return -1;
313 } 320 }
314 } 321 }
322#endif
315 } else { 323 } else {
316 bb_error_msg("internal error: unrecognized file type"); 324 bb_error_msg("internal error: unrecognized file type");
317 return -1; 325 return -1;
@@ -319,6 +327,7 @@ int copy_file(const char *source, const char *dest, int flags)
319 327
320 preserve_status: 328 preserve_status:
321 329
330#ifndef __MINGW32__
322 if (flags & FILEUTILS_PRESERVE_STATUS 331 if (flags & FILEUTILS_PRESERVE_STATUS
323 /* Cannot happen: */ 332 /* Cannot happen: */
324 /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */ 333 /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */
@@ -336,6 +345,7 @@ int copy_file(const char *source, const char *dest, int flags)
336 if (chmod(dest, source_stat.st_mode) < 0) 345 if (chmod(dest, source_stat.st_mode) < 0)
337 bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest); 346 bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest);
338 } 347 }
348#endif
339 349
340 return status; 350 return status;
341} 351}