static int do_rename( char* src, char *dst, struct stat *st) { char adsrc[ MAXPATHLEN + 1]; struct stat tmp_st; if (!stat(dst, &tmp_st)) { fprintf (stderr, "error: cannot rename %s to %s, destination exists\n", src, dst); return -1; } if ( rename( src, dst ) < 0 ) { fprintf (stderr, "error: cannot rename %s to %s, %s\n", src, dst, strerror(errno)); return -1; } if (S_ISDIR(st->st_mode)) return 0; strcpy( adsrc, ad_path( src, 0 )); if (rename( adsrc, ad_path( dst, 0 )) < 0 ) { struct stat ad_st; if (errno == ENOENT) { if (stat(adsrc, &ad_st)) /* source has no ressource fork, */ return 0; } else { fprintf (stderr, "failed to rename resource fork, error: %s\n", strerror(errno)); return -1; } } return 0; }
static int ad_conv_v22ea(const char *path, const struct stat *sp, const struct vol *vol) { EC_INIT; const char *adpath; int adflags = S_ISDIR(sp->st_mode) ? ADFLAGS_DIR : 0; become_root(); EC_ZERO( ad_conv_v22ea_hf(path, sp, vol) ); EC_ZERO( ad_conv_v22ea_rf(path, sp, vol) ); EC_NULL( adpath = ad_path(path, adflags) ); LOG(log_debug, logtype_default,"ad_conv_v22ea_hf(\"%s\"): deleting adouble:v2 file: \"%s\"", path, fullpathname(adpath)); unlink(adpath); EC_CLEANUP: if (errno == ENOENT) EC_STATUS(0); unbecome_root(); EC_EXIT; }