~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Aaron Bentley
  • Date: 2006-04-21 23:50:55 UTC
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: aaron.bentley@utoronto.ca-20060421235055-cfddf190f5135d73
Better illegal pathname check for Windows

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                           BzrBadParameterNotUnicode,
36
36
                           NoSuchFile,
37
37
                           PathNotChild,
 
38
                           IllegalPath,
38
39
                           )
39
40
from bzrlib.trace import mutter
40
41
 
668
669
        return path[:-1]
669
670
    else:
670
671
        return path
 
672
 
 
673
 
 
674
_validWin32PathRE = re.compile(r'^([A-Za-z]:[/\\])?[^:<>*"?\|]*$')
 
675
 
 
676
 
 
677
def check_legal_path(path):
 
678
    """Check whether the supplied path is legal.  
 
679
    This is only required on Windows, so we don't test on other platforms
 
680
    right now.
 
681
    """
 
682
    if sys.platform != "win32":
 
683
        return
 
684
    if _validWin32PathRE.match(path) is None:
 
685
        raise IllegalPath(path)