Eluze <elu...@gmail.com> writes: > Phil Holmes wrote >>> >>> And while we are at it: the loop has the condition >>> while os.path.exists(back_up) and os.path.isfile(back_up): >>> for skipping over existing files. The second part of the condition is >>> nonsensical since it means that a name will be used for backing up even >>> if it is already taken by a directory or fifo or socket. >>> >>> https://codereview.appspot.com/14040043/ >> >> I presume Eluze put it in for a specific reason which I don't know. >> Eluze? > > well - as you certainly guess, the code isn't purely mine and I was already > wondering why there are these two conditions. > > now reading a little bit more I found that "A path is an unambiguous pointer > to a resource in the file system. It can either point to a file or to a > directory." > > this seems exactly what we don't want, we don't deal with directories here - > so it's sufficient to test if it is an existing /file/: > *os.path.isfile(back_up)* should be used solely.
Wrong. os.path.exists (back_up) should be used solely since we are looking for an _unused_ file name. If there is a directory called file.ly.~1~ we have to skip this just as much in our search as if there is a file called file.ly.~1~ as we don't want to overwrite either existing files or existing directories. -- David Kastrup _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel