138
138
return "<%s of %s>" % (self.__class__.__name__,
141
def _rel(self, filename):
141
def abspath(self, filename):
142
142
return os.path.join(self.basedir, filename)
144
144
def has_filename(self, filename):
145
return os.path.exists(self._rel(filename))
145
return os.path.exists(self.abspath(filename))
147
147
def get_file(self, file_id):
148
148
return self.get_file_byname(self.id2path(file_id))
150
150
def get_file_byname(self, filename):
151
return file(self._rel(filename), 'rb')
151
return file(self.abspath(filename), 'rb')
153
153
def _get_store_filename(self, file_id):
154
return self._rel(self.id2path(file_id))
154
return self.abspath(self.id2path(file_id))
156
156
def has_id(self, file_id):
157
157
# files that have been deleted are excluded
158
158
if not self.inventory.has_id(file_id):
160
return os.access(self._rel(self.inventory.id2path(file_id)), os.F_OK)
160
return os.access(self.abspath(self.inventory.id2path(file_id)), os.F_OK)
162
162
def get_file_size(self, file_id):
163
163
return os.stat(self._get_store_filename(file_id))[ST_SIZE]
179
179
def file_kind(self, filename):
180
if isfile(self._rel(filename)):
180
if isfile(self.abspath(filename)):
182
elif isdir(self._rel(filename)):
182
elif isdir(self.abspath(filename)):
183
183
return 'directory'