From b7f63bc93d524cef99f9c445bdded50b091218ac Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 17 Nov 2019 15:40:09 -0800 Subject: [PATCH] Make devnull check compatible with Windows --- src/ocrmypdf/_sync.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/_sync.py b/src/ocrmypdf/_sync.py index c02543b7..4c25b300 100644 --- a/src/ocrmypdf/_sync.py +++ b/src/ocrmypdf/_sync.py @@ -304,6 +304,13 @@ class NeverRaise(Exception): pass # pylint: disable=unnecessary-pass +def samefile(f1, f2): + if os.name == 'nt': + return f1 == f2 + else: + return os.path.samefile(f1, f2) + + def run_pipeline(options, api=False): log = make_logger(options, __name__) @@ -339,7 +346,7 @@ def run_pipeline(options, api=False): if options.output_file == '-': log.info("Output sent to stdout") - elif os.path.samefile(options.output_file, os.devnull): + elif samefile(options.output_file, os.devnull): pass # Say nothing when sending to dev null else: if options.output_type.startswith('pdfa'):