* path.cc (path_conv::check): Set case_clash even if pcheck_case

is set to PCHECK_ADJUST when a case clash is given for the last
        component in path.
        (symlink_info::case_check): Ditto.
        * syscalls.cc (_rename): Avoid overwriting an already existing file
        if a case clash is given even if pcheck_case is set to PCHECK_ADJUST.
This commit is contained in:
Corinna Vinschen 2001-04-17 11:47:37 +00:00
parent 77eb506d60
commit 0f56512627
2 changed files with 18 additions and 10 deletions

View File

@ -324,9 +324,18 @@ path_conv::check (const char *src, unsigned opt,
if (sym.case_clash) if (sym.case_clash)
{ {
case_clash = TRUE; if (pcheck_case == PCHECK_STRICT)
error = ENOENT; {
goto out; case_clash = TRUE;
error = ENOENT;
goto out;
}
/* If pcheck_case==PCHECK_ADJUST the case_clash is remembered
if the last component is concerned. This allows functions
which shall create files to avoid overriding already existing
files with another case. */
if (!component)
case_clash = TRUE;
} }
if (!(opt & PC_SYM_IGNORE)) if (!(opt & PC_SYM_IGNORE))
@ -2754,13 +2763,12 @@ symlink_info::case_check (const char *path, char *orig_path)
/* If that part of the component exists, check the case. */ /* If that part of the component exists, check the case. */
if (strcmp (c, data.cFileName)) if (strcmp (c, data.cFileName))
{ {
case_clash = TRUE;
/* If check is set to STRICT, a wrong case results /* If check is set to STRICT, a wrong case results
in returning a ENOENT. */ in returning a ENOENT. */
if (pcheck_case == PCHECK_STRICT) if (pcheck_case == PCHECK_STRICT)
{ return FALSE;
case_clash = TRUE;
return FALSE;
}
/* PCHECK_ADJUST adjusts the case in the incoming /* PCHECK_ADJUST adjusts the case in the incoming
path which points to the path in *this. */ path which points to the path in *this. */

View File

@ -1246,7 +1246,7 @@ _rename (const char *oldpath, const char *newpath)
/* Shortcut hack. */ /* Shortcut hack. */
char new_lnk_buf[MAX_PATH + 5]; char new_lnk_buf[MAX_PATH + 5];
if (real_old.issymlink () && !real_new.error) if (real_old.issymlink () && !real_new.error && !real_new.case_clash)
{ {
int len_old = strlen (real_old.get_win32 ()); int len_old = strlen (real_old.get_win32 ());
if (strcasematch (real_old.get_win32 () + len_old - 4, ".lnk")) if (strcasematch (real_old.get_win32 () + len_old - 4, ".lnk"))
@ -1258,10 +1258,10 @@ _rename (const char *oldpath, const char *newpath)
} }
} }
if (real_new.error) if (real_new.error || real_new.case_clash)
{ {
syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath); syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath);
set_errno (real_new.error); set_errno (real_new.case_clash ? ECASECLASH : real_new.error);
return -1; return -1;
} }