On Fri, Jan 14, 2011 at 8:44 PM, Tim Abell <tim@xxxxxxxxxxxxx> wrote: >        Âelse if (lstat(dst, &st) == 0) { > -            bad = "destination exists"; > -            if (force) { > -                /* > -                Â* only files can overwrite each other: > -                Â* check both source and destination > -                Â*/ > -                if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { > -                    warning("%s; will overwrite!", bad); > -                    bad = NULL; > -                } else > -                    bad = "Cannot overwrite"; > +            /* If we are on a case insensitive files= system (windows) http://is.gd/kyxgg > +            Â* and we are only changing the case of the file then lstat for the > +            Â* destination will return != 0 because it sees the source file. > +            Â* To prevent this causing failure, lstat is used to get the inode of the src > +            Â* and see if it's actually the same file. > +            Â*/ > +            lstat(src, &src_st); //get file serial number (inode) for source > +            #warning("src inode: %s, dst inode: %s", src_st.st_ino, st.st_ino); > +            if (src_st.st_ino != st.st_ino) { > +                bad = "destination exists"; > +                if (force) { > +                    /* > +                    Â* only files can overwrite each other: > +                    Â* check both source and destination > +                    Â*/ > +                    if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { > +                        warning("%s; will overwrite!", bad); > +                        bad = NULL; > +                    } else > +                        bad = "Cannot overwrite"; > +                } >            Â} >        Â} else if (string_list_has_string(&src_for_dst, dst)) >            Âbad = "multiple sources for the same target"; I wonder if we can make lstat_case() that would only return 0 if it matches exactly the filename, even on FAT. FindFirstFile/FindNextFile should return true file name, I think. If not, we can make lstat_case() take two paths (src and dst) and move all inode comparison code in there. Much cleaner. -- Duy ÿô.nÇ·®+%˱é¥wÿº{.nÇ· ßØnr¡öë¨è&£ûz¹Þúzf£¢·h§~Ûÿÿïÿê_èæ+v¨þ)ßø