Skip to content

Commit 3402ac2

Browse files
author
Peter Szabo
committed
fixed filenames and program name lookups on win32; added pdfsizeopt_win32exec detection
1 parent c007730 commit 3402ac2

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/pdfsizeopt/main.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def GetGsCommand():
100100
gs_cmd = os.getenv('PDFSIZEOPT_GS', None)
101101
if gs_cmd is None:
102102
if sys.platform.startswith('win'): # Windows: win32 or win64
103-
gs_cmd = FindOnPath(r'pdfsizeopt_gswin\gswin32c.exe')
103+
gs_cmd = FindOnPath(os.path.join('pdfsizeopt_gswin', 'gswin32c.exe'))
104104
if gs_cmd is None:
105105
data = None
106106
else:
@@ -8017,7 +8017,14 @@ def main(argv):
80178017
used_script_dir = script_dir
80188018
else:
80198019
used_script_dir = os.path.dirname(os.path.abspath(main_file))
8020-
libexec_dir = os.path.join(used_script_dir, 'pdfsizeopt_libexec')
8020+
libexec_dir = None
8021+
if libexec_dir is None and sys.platform.startswith('win'):
8022+
xdir = os.path.join(used_script_dir, 'pdfsizeopt_win32exec')
8023+
if os.path.isdir(xdir):
8024+
libexec_dir = xdir
8025+
xdir = None
8026+
if libexec_dir is None:
8027+
libexec_dir = os.path.join(used_script_dir, 'pdfsizeopt_libexec')
80218028
avian_pathname = None
80228029
if os.path.isdir(libexec_dir):
80238030
extrapath_dir = libexec_dir
@@ -8027,9 +8034,13 @@ def main(argv):
80278034
else:
80288035
extrapath_dir = used_script_dir
80298036
if sys.platform.startswith('win'):
8030-
extrapath_dir = ShellQuote(extrapath_dir)
8037+
# ShellQuote(...) doesn't work in wine-1.6.2, is it needed on normal
8038+
# Windows (e.g. for running sam2p).
8039+
# extrapath_dir = ShellQuote(extrapath_dir)
8040+
pass
80318041
os.environ['PATH'] = '%s%s%s' % (
80328042
extrapath_dir, os.pathsep, os.getenv('PATH', ''))
8043+
#assert 0, os.environ['PATH']
80338044
if not argv:
80348045
argv = ['pdfsizeopt']
80358046
if len(argv) == 1:
@@ -8186,6 +8197,14 @@ def main(argv):
81868197
except getopt.GetoptError, exc:
81878198
print >>sys.stderr, 'error: in command line: %s' % exc
81888199
sys.exit(1)
8200+
if sys.platform.startswith('win'):
8201+
# pngout doesn't work otherwise, because it treats / as flag.
8202+
# This fix affects wine.
8203+
if file_name.startswith('/'):
8204+
file_name = file_name.replace('/', os.sep)
8205+
if output_file_name.startswith('/'):
8206+
output_file_name = output_file_name.replace('/', os.sep)
8207+
81898208
if do_generate_object_stream and not do_generate_xref_stream:
81908209
print >>sys.stderr, ('error: --do-generate-object-stream=yes requires '
81918210
'--do-generate-xref-stream=yes')

pdfsizeopt.single

176 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)