~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/fakevfat.py

(FakeVFAT) implement more transport methods; disallow bad characters

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
"""
40
40
 
 
41
import re
 
42
 
41
43
from bzrlib.errors import TransportNotPossible
42
44
from bzrlib.transport.decorator import TransportDecorator, DecoratorServer
43
45
 
55
57
 
56
58
    This is requested via the 'vfat+' prefix to get_transport().
57
59
 
58
 
    This is intended only for use in testing.
 
60
    This is intended only for use in testing and doesn't implement every
 
61
    method very well yet.
59
62
 
60
63
    This transport is typically layered on a local or memory transport
61
64
    which actually stored the files.
72
75
        The name is returned as it will be stored on disk.  This raises an
73
76
        error if there are invalid characters in the name.
74
77
        """
 
78
        if re.search(r'[?*:;<>]', name):
 
79
            raise ValueError("illegal characters for VFAT filename: %r" % name)
75
80
        return name.lower()
76
81
 
 
82
    def get(self, relpath):
 
83
        return self._decorated.get(self._squash_name(relpath))
 
84
 
77
85
    def mkdir(self, relpath, mode=None):
78
86
        return self._decorated.mkdir(self._squash_name(relpath), 0755)
79
87
 
80
88
    def has(self, relpath):
81
89
        return self._decorated.has(self._squash_name(relpath))
82
90
 
 
91
    def readv(self, relpath, offsets):
 
92
        return self._decorated.readv(self._squash_name(relpath), offsets)
 
93
 
 
94
    def put(self, relpath, f, mode=None):
 
95
        return self._decorated.put(self._squash_name(relpath), f, mode)
 
96
 
83
97
 
84
98
class FakeVFATServer(DecoratorServer):
85
99
    """A server that suggests connections through FakeVFATTransportDecorator