- return yaffs_ChangeObjectName(obj,newDir,newName,force);
+
+ // Now do the handling for an existing target, if there is one
+
+ existingTarget = yaffs_FindObjectByName(newDir,newName);
+ if(existingTarget &&
+ existingTarget->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
+ !list_empty(&existingTarget->variant.directoryVariant.children))
+ {
+ // There is a target that is a non-empty directory, so we have to fail
+ return YAFFS_FAIL; // EEXIST or ENOTEMPTY
+ }
+ else if(existingTarget)
+ {
+ // Nuke the target first, using shadowing
+ yaffs_ChangeObjectName(obj,newDir,newName,force,existingTarget->objectId);
+ yaffs_Unlink(newDir,newName);
+ }
+
+
+ return yaffs_ChangeObjectName(obj,newDir,newName,force,0);