Commit 8f5515e8 authored by Jocelyn Turcotte's avatar Jocelyn Turcotte
Browse files

<third_party/WebKit> Prevent a python IOError on Windows due to MAX_PATH


Running python down into the WebKit directory structure and referring
a file relatively to the build directory can easily spill over the
260 char limit on Windows.

Resolve the absolute path using join and normpath to work around the
issue.

Change-Id: I6e89aad542761adcbd821b05f0cc6e9d489dced5
Reviewed-by: default avatarAndras Becsi <andras.becsi@digia.com>
No related merge requests found
Showing with 10 additions and 0 deletions
......@@ -27,24 +27,33 @@ def idl_filename_to_interface_name(idl_filename):
# Basic file reading/writing
################################################################################
def abs(filename):
# open, abspath, etc. are all limited to the 260 char MAX_PATH and this causes
# problems when we try to resolve long relative paths in the WebKit directory structure.
return os.path.normpath(os.path.join(os.getcwd(), filename))
def get_file_contents(filename):
filename = abs(filename)
with open(filename) as f:
return f.read()
def read_file_to_list(filename):
"""Returns a list of (stripped) lines for a given filename."""
filename = abs(filename)
with open(filename) as f:
return [line.rstrip('\n') for line in f]
def read_pickle_files(pickle_filenames):
for pickle_filename in pickle_filenames:
pickle_filename = abs(pickle_filename)
with open(pickle_filename) as pickle_file:
yield pickle.load(pickle_file)
def write_file(new_text, destination_filename, only_if_changed):
destination_filename = abs(destination_filename)
if only_if_changed and os.path.isfile(destination_filename):
with open(destination_filename) as destination_file:
if destination_file.read() == new_text:
......@@ -54,6 +63,7 @@ def write_file(new_text, destination_filename, only_if_changed):
def write_pickle_file(pickle_filename, data, only_if_changed):
pickle_filename = abs(pickle_filename)
if only_if_changed and os.path.isfile(pickle_filename):
with open(pickle_filename) as pickle_file:
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment