def save_as(self, path):
if not self.content:
return 0
try:
with open(path, 'w') as f:
f.write(self.content)
f.flush()
os.fsync(f.fileno())
written = os.stat(path).st_size
except IOError:
written = 0
return written