diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-04 08:40:04 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-04 08:40:04 +0000 |
commit | 62f19f8a31706a1ae65eeccba4155456e879c7d9 (patch) | |
tree | 157ce8c29b890c19fdc7d6f223ecb65fd1df0f51 /rdiff-backup/rdiff_backup/rpath.py | |
parent | 64976e6afefff455ee9515218942a65c6ff5eede (diff) | |
download | rdiff-backup-62f19f8a31706a1ae65eeccba4155456e879c7d9.tar.gz |
Initial checkin of journal code
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@274 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/rpath.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/rpath.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index fb2c255..0b18e19 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -736,6 +736,14 @@ class RPath(RORPath): comps = normed.path.split("/") return "/".join(comps[:-1]), comps[-1] + def get_parent_rp(self): + """Return new RPath of directory self is in""" + if self.index: + return self.__class__(self.conn, self.base, self.index[:-1]) + dirname = self.dirsplit()[0] + if dirname: return self.__class__(self.conn, dirname) + else: return self.__class__(self.conn, "/") + def newpath(self, newpath, index = ()): """Return new RPath with the same connection but different path""" return self.__class__(self.conn, newpath, index) @@ -851,6 +859,26 @@ class RPath(RORPath): else: raise RPathException self.setdata() + def fsync(self, fp = None): + """fsync the current file or directory + + If fp is none, get the file description by opening the file. + This can be useful for directories. + + """ + if not fp: + fp = self.open("rb") + os.fsync(fp.fileno()) + assert not fp.close() + else: os.fsync(fp.fileno()) + + def get_data(self): + """Open file as a regular file, read data, close, return data""" + fp = self.open("rb") + s = fp.read() + assert not fp.close() + return s + class RPathFileHook: """Look like a file, but add closing hook""" |