We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e1ec73 commit d8b544dCopy full SHA for d8b544d
src/sync.py
@@ -0,0 +1,34 @@
1
+#!/usr/bin/python3
2
+
3
+import os
4
+import sys
5
+from optparse import OptionParser
6
7
8
+def lazybox_sync(_, filenames: list[str]):
9
+ if filenames:
10
+ failed = False
11
12
+ for name in filenames:
13
+ try:
14
+ with open(name, "r+") as io:
15
+ os.fsync(io)
16
+ except OSError as e:
17
+ failed = True
18
+ print(e, file=sys.stderr)
19
20
+ if failed:
21
+ sys.exit(1)
22
+ else:
23
+ os.sync()
24
25
26
+if __name__ == "__main__":
27
+ parser = OptionParser(
28
+ usage="Usage: %prog [FILE]...",
29
+ description="Sync the filesystem or write each FILE's blocks to disk.",
30
+ add_help_option=False,
31
+ )
32
+ parser.add_option("--help", action="help", help="show usage information and exit")
33
34
+ lazybox_sync(*parser.parse_args())
0 commit comments