~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-28 02:24:18 UTC
  • Revision ID: mbp@sourcefrog.net-20050328022418-9d37f56361aa18e9
doc: more on ignore patterns

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
__author__ = "Martin Pool <mbp@canonical.com>"
25
25
 
26
26
import os, tempfile, types, osutils
 
27
from stat import ST_SIZE
27
28
from StringIO import StringIO
28
29
from trace import mutter
29
30
 
96
97
            filename = self._path(fileid)
97
98
            f = file(filename, 'wb')
98
99
            f.write(content)
99
 
            f.flush()
100
 
            os.fsync(f.fileno())
 
100
            ## f.flush()
 
101
            ## os.fsync(f.fileno())
101
102
            f.close()
102
103
            osutils.make_readonly(filename)
103
104
 
110
111
    def __iter__(self):
111
112
        return iter(os.listdir(self._basedir))
112
113
 
 
114
    def __len__(self):
 
115
        return len(os.listdir(self._basedir))
 
116
 
113
117
    def __getitem__(self, fileid):
114
118
        """Returns a file reading from a particular entry."""
115
119
        return file(self._path(fileid), 'rb')
116
120
 
 
121
    def total_size(self):
 
122
        """Return (count, bytes)"""
 
123
        total = 0
 
124
        count = 0
 
125
        for fid in self:
 
126
            count += 1
 
127
            total += os.stat(self._path(fid))[ST_SIZE]
 
128
        return count, total
 
129
 
117
130
    def delete_all(self):
118
131
        for fileid in self:
119
132
            self.delete(fileid)