diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-01 17:40:13 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-01 17:40:13 +0000 |
commit | 836f134c56bfa714217ca12a73482205c1480774 (patch) | |
tree | 5c5b9d938a712e09831bdd32022e1b3716c5fbdf /base/event_recorder.cc | |
parent | d46d6f3b80099ce0c630185a2e86b649bba49254 (diff) | |
download | chromium_src-836f134c56bfa714217ca12a73482205c1480774.zip chromium_src-836f134c56bfa714217ca12a73482205c1480774.tar.gz chromium_src-836f134c56bfa714217ca12a73482205c1480774.tar.bz2 |
Cross-platform wrappers for fopen, _wfopen_s, etc.
Patch by Paweł Hajdan jr <phajdan.jr@gmail.com>.
http://codereview.chromium.org/6005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/event_recorder.cc')
-rw-r--r-- | base/event_recorder.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/base/event_recorder.cc b/base/event_recorder.cc index a7650a3..ab7fcf9 100644 --- a/base/event_recorder.cc +++ b/base/event_recorder.cc @@ -6,6 +6,7 @@ #include <mmsystem.h> +#include "base/file_util.h" #include "base/logging.h" #include "base/time.h" @@ -48,7 +49,8 @@ bool EventRecorder::StartRecording(const std::wstring& filename) { // Open the recording file. DCHECK(file_ == NULL); - if (_wfopen_s(&file_, filename.c_str(), L"wb+") != 0) { + file_ = file_util::OpenFile(filename, "wb+"); + if (!file_) { DLOG(ERROR) << "EventRecorder could not open log file"; return false; } @@ -61,7 +63,7 @@ bool EventRecorder::StartRecording(const std::wstring& filename) { GetModuleHandle(NULL), 0); if (!journal_hook_) { DLOG(ERROR) << "EventRecorder Record Hook failed"; - fclose(file_); + file_util::CloseFile(file_); return false; } @@ -82,7 +84,7 @@ void EventRecorder::StopRecording() { ::timeEndPeriod(1); DCHECK(file_ != NULL); - fclose(file_); + file_util::CloseFile(file_); file_ = NULL; journal_hook_ = NULL; @@ -98,14 +100,15 @@ bool EventRecorder::StartPlayback(const std::wstring& filename) { // Open the recording file. DCHECK(file_ == NULL); - if (_wfopen_s(&file_, filename.c_str(), L"rb") != 0) { + file_ = file_util::OpenFile(filename, "rb"); + if (!file_) { DLOG(ERROR) << "EventRecorder Playback could not open log file"; return false; } // Read the first event from the record. if (fread(&playback_msg_, sizeof(EVENTMSG), 1, file_) != 1) { DLOG(ERROR) << "EventRecorder Playback has no records!"; - fclose(file_); + file_util::CloseFile(file_); return false; } @@ -147,7 +150,7 @@ void EventRecorder::StopPlayback() { } DCHECK(file_ != NULL); - fclose(file_); + file_util::CloseFile(file_); file_ = NULL; ::timeEndPeriod(1); |