cef/tools/file_util.py
Marshall Greenblatt 6a7b6d5038 libcef: Update due to underlying chromium changes.
- Add the printing project and delete duplicated files from the CEF printing directory.
- Add media-related projects and support for <video> and <image> tags.
- Use WebKit::WebHTTPBody instead of net::UploadData for web requests.
- Numerous changes due to continued cleanup of webkit/glue and webkit/api/public.
- Use a separate BrowserWebViewDelegate instance for popup windows.

libcef:
- Add support for printing to file.
- Use WebFrame::GetFullPageHtml() instead of webkit_glue::GetDocumentString().
- Parse extra header values in RequestProxy for passing to CefHandler::HandleBeforeResourceLoad().
- Add urlmon.lib dependency in libcef.vsprops.

tools:
- Add the patch application tool (patcher.py).

patch:
- New project for applying required patches to the Chromium source tree (issue #47).
- Add webkit_glue.patch for http://codereview.chromium.org/160004

cefclient:
- Add new test for submitting and handling requests.
- Don't change navigation button state for popup windows.
- Fix problem on Vista where the string returned by EM_GETLINE is not NULL-terminated.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@32 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2009-07-24 18:37:00 +00:00

45 lines
1.3 KiB
Python

# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
import os
import shutil
import sys
import time
def read_file(name, normalize = True):
""" Function for reading a file. """
try:
f = open(name, 'r')
# read the data
data = f.read()
if normalize:
# normalize line endings
data = data.replace("\r\n", "\n")
return data
except IOError, (errno, strerror):
sys.stderr.write('Failed to read file '+filename+': '+strerror)
raise
else:
f.close()
def write_file(name, data):
""" Function for writing a file. """
try:
f = open(name, 'w')
# write the data
f.write(data)
except IOError, (errno, strerror):
sys.stderr.write('Failed to write file '+name+': '+strerror)
raise
else:
f.close()
def file_exists(name):
""" Returns true if the file currently exists. """
return os.path.exists(name)
def backup_file(name):
""" Renames the file to a name that includes the current time stamp. """
shutil.move(name, name+'.'+time.strftime('%Y-%m-%d-%H-%M-%S'))