~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Robert Collins
  • Date: 2005-09-23 09:25:16 UTC
  • mto: (1092.3.4)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: robertc@robertcollins.net-20050923092516-e2c3c0f31288669d
Merge what applied of Alexander Belchenko's win32 patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
    finally:
114
114
        outf.close()
115
115
 
116
 
def rename(path_from, path_to):
117
 
    """Basically the same as os.rename() just special for win32"""
118
 
    if sys.platform == 'win32':
119
 
        try:
120
 
            os.remove(path_to)
121
 
        except OSError, e:
122
 
            if e.errno != e.ENOENT:
123
 
                raise
124
 
    os.rename(path_from, path_to)
125
 
 
126
 
 
127
 
 
 
116
if os.name == 'nt':
 
117
    import shutil
 
118
    rename = shutil.move
 
119
else:
 
120
    rename = os.rename
128
121
 
129
122
 
130
123
def isdir(f):
135
128
        return False
136
129
 
137
130
 
138
 
 
139
131
def isfile(f):
140
132
    """True if f is a regular file."""
141
133
    try:
154
146
    The empty string as a dir name is taken as top-of-tree and matches 
155
147
    everything.
156
148
    
157
 
    >>> is_inside('src', 'src/foo.c')
 
149
    >>> is_inside('src', os.path.join('src', 'foo.c'))
158
150
    True
159
151
    >>> is_inside('src', 'srccontrol')
160
152
    False
161
 
    >>> is_inside('src', 'src/a/a/a/foo.c')
 
153
    >>> is_inside('src', os.path.join('src', 'a', 'a', 'a', 'foo.c'))
162
154
    True
163
155
    >>> is_inside('foo.c', 'foo.c')
164
156
    True