From 8f5515e887f99194cad0a3b8bfe30c91b4466d10 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte <jocelyn.turcotte@digia.com> Date: Fri, 5 Sep 2014 17:26:50 +0200 Subject: [PATCH] <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: Andras Becsi <andras.becsi@digia.com> --- .../WebKit/Source/bindings/scripts/utilities.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/chromium/third_party/WebKit/Source/bindings/scripts/utilities.py b/chromium/third_party/WebKit/Source/bindings/scripts/utilities.py index 0aeabc20b36..f42918057a4 100644 --- a/chromium/third_party/WebKit/Source/bindings/scripts/utilities.py +++ b/chromium/third_party/WebKit/Source/bindings/scripts/utilities.py @@ -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: -- GitLab