static int cfs_rename(const char *src, const char *dst) { dir_entry *src_de = path_info(src); if (!src_de) return -ENOENT; if (src_de->isdir) return -EISDIR; if (cloudfs_copy_object(src, dst)) { /* FIXME this isn't quite right as doesn't preserve last modified */ update_dir_cache(dst, src_de->size, 0, 0); return cfs_unlink(src); } return -EIO; }
static int cfs_rename(const char* src, const char* dst) { debugf(DBG_LEVEL_NORM, KBLU"cfs_rename(%s, %s)", src, dst); dir_entry* src_de = path_info(src); if (!src_de) { debugf(DBG_LEVEL_NORM, KRED"exit 0: cfs_rename(%s,%s) not-found", src, dst); return -ENOENT; } if (src_de->isdir) { debugf(DBG_LEVEL_NORM, KRED"exit 1: cfs_rename(%s,%s) cannot rename dirs!", src, dst); return -EISDIR; } if (cloudfs_copy_object(src, dst)) { /* FIXME this isn't quite right as doesn't preserve last modified */ //fix done in cloudfs_copy_object() update_dir_cache(dst, src_de->size, 0, 0); int result = cfs_unlink(src); dir_entry* dst_de = path_info(dst); if (!dst_de) debugf(DBG_LEVEL_NORM, KRED"cfs_rename(%s,%s) dest-not-found-in-cache", src, dst); else { debugf(DBG_LEVEL_NORM, KBLU"cfs_rename(%s,%s) upload ok", src, dst); //copy attributes, shortcut, rather than forcing a download from cloud copy_dir_entry(src_de, dst_de); } debugf(DBG_LEVEL_NORM, KBLU"exit 3: cfs_rename(%s,%s)", src, dst); return result; } debugf(DBG_LEVEL_NORM, KRED"exit 4: cfs_rename(%s,%s) io error", src, dst); return -EIO; }