- /* check for illegal characters */
- if ((vol->v_flags & AFPVOL_MSWINDOWS) &&
- strpbrk(newname, MSWINDOWS_BADCHARS))
- return AFPERR_PARAM;
-
- upath = mtoupath(vol, newname);
-
- if ((vol->v_flags & AFPVOL_NOHEX) && strchr(upath, '/'))
- return AFPERR_PARAM;
-
- if (!validupath(vol, upath))
- return AFPERR_EXIST;
-
- /* source == destination. we just silently accept this. */
- if (curdir == sdir) {
- if (strcmp(oldname, newname) == 0)
- return AFP_OK;
-
- /* deal with case insensitive, case-preserving filesystems. */
- if ((stat(upath, &st) == 0) && strdiacasecmp(oldname, newname))
- return AFPERR_EXIST;
-
- } else if (stat(upath, &st ) == 0)
- return( AFPERR_EXIST );
-
- if ( !odir ) {
- if (of_findname(vol, curdir, newname)) {
- rc = AFPERR_BUSY;
- } else if ((rc = renamefile( p, upath, newname,
- vol_noadouble(vol) )) == AFP_OK) {
- /* if it's still open, rename the ofork as well. */
- rc = of_rename(vol, sdir, oldname, curdir, newname);
- }
- } else {
- rc = renamedir(p, upath, odir, curdir, newname, vol_noadouble(vol));
- }