##// END OF EJS Templates
util: warn when adding paths ending with \...
Mads Kiilerich -
r20000:0849d280 stable
parent child Browse files
Show More
@@ -563,7 +563,7 b' def copyfiles(src, dst, hardlink=None):'
563 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split()
563 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split()
564 _winreservedchars = ':*?"<>|'
564 _winreservedchars = ':*?"<>|'
565 def checkwinfilename(path):
565 def checkwinfilename(path):
566 '''Check that the base-relative path is a valid filename on Windows.
566 r'''Check that the base-relative path is a valid filename on Windows.
567 Returns None if the path is ok, or a UI string describing the problem.
567 Returns None if the path is ok, or a UI string describing the problem.
568
568
569 >>> checkwinfilename("just/a/normal/path")
569 >>> checkwinfilename("just/a/normal/path")
@@ -577,11 +577,19 b' def checkwinfilename(path):'
577 >>> checkwinfilename("foo/bar/bla:.txt")
577 >>> checkwinfilename("foo/bar/bla:.txt")
578 "filename contains ':', which is reserved on Windows"
578 "filename contains ':', which is reserved on Windows"
579 >>> checkwinfilename("foo/bar/b\07la.txt")
579 >>> checkwinfilename("foo/bar/b\07la.txt")
580 "filename contains '\\\\x07', which is invalid on Windows"
580 "filename contains '\\x07', which is invalid on Windows"
581 >>> checkwinfilename("foo/bar/bla ")
581 >>> checkwinfilename("foo/bar/bla ")
582 "filename ends with ' ', which is not allowed on Windows"
582 "filename ends with ' ', which is not allowed on Windows"
583 >>> checkwinfilename("../bar")
583 >>> checkwinfilename("../bar")
584 >>> checkwinfilename("foo\\")
585 "filename ends with '\\', which is invalid on Windows"
586 >>> checkwinfilename("foo\\/bar")
587 "directory name ends with '\\', which is invalid on Windows"
584 '''
588 '''
589 if path.endswith('\\'):
590 return _("filename ends with '\\', which is invalid on Windows")
591 if '\\/' in path:
592 return _("directory name ends with '\\', which is invalid on Windows")
585 for n in path.replace('\\', '/').split('/'):
593 for n in path.replace('\\', '/').split('/'):
586 if not n:
594 if not n:
587 continue
595 continue
General Comments 0
You need to be logged in to leave comments. Login now