mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-15 00:21:56 +00:00
Compose platform_base from the platform-specific functionality
Noticed while working on the windows branch.
This commit is contained in:
parent
a1c4d45920
commit
2d90bb2c55
1 changed files with 16 additions and 2 deletions
|
@ -1,5 +1,17 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
"""
|
||||||
|
platform base module
|
||||||
|
====================
|
||||||
|
|
||||||
|
Contains platform API implementations based on what Python itself provides. More specific
|
||||||
|
APIs are stubs in this module.
|
||||||
|
|
||||||
|
When functions in this module use platform APIs themselves they access the public
|
||||||
|
platform API: that way platform APIs provided by the platform-specific support module
|
||||||
|
are correctly composed into the base functionality.
|
||||||
|
"""
|
||||||
|
|
||||||
API_VERSION = 3
|
API_VERSION = 3
|
||||||
|
|
||||||
fdatasync = getattr(os, 'fdatasync', os.fsync)
|
fdatasync = getattr(os, 'fdatasync', os.fsync)
|
||||||
|
@ -80,16 +92,18 @@ class SyncFile:
|
||||||
Synchronize file contents. Everything written prior to sync() must become durable before anything written
|
Synchronize file contents. Everything written prior to sync() must become durable before anything written
|
||||||
after sync().
|
after sync().
|
||||||
"""
|
"""
|
||||||
|
from .. import platform
|
||||||
self.fd.flush()
|
self.fd.flush()
|
||||||
fdatasync(self.fileno)
|
platform.fdatasync(self.fileno)
|
||||||
if hasattr(os, 'posix_fadvise'):
|
if hasattr(os, 'posix_fadvise'):
|
||||||
os.posix_fadvise(self.fileno, 0, 0, os.POSIX_FADV_DONTNEED)
|
os.posix_fadvise(self.fileno, 0, 0, os.POSIX_FADV_DONTNEED)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""sync() and close."""
|
"""sync() and close."""
|
||||||
|
from .. import platform
|
||||||
self.sync()
|
self.sync()
|
||||||
self.fd.close()
|
self.fd.close()
|
||||||
sync_dir(os.path.dirname(self.fd.name))
|
platform.sync_dir(os.path.dirname(self.fd.name))
|
||||||
|
|
||||||
|
|
||||||
def swidth(s):
|
def swidth(s):
|
||||||
|
|
Loading…
Add table
Reference in a new issue