Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: platform_reader.cc

Issue 3530001: first cut: establishes base helper classes and main (Closed) Base URL: http://git.chromium.org/git/cros_boot_mode.git
Patch Set: truncation is bad, m'kay. . . Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « platform_reader.h ('k') | platform_switch.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Defines the PlatformReader base class. By default, it will read an integer
6 // from a file and assigned it to a PlatformValue which is
7 // implementation-specific.
8
9 #include "platform_reader.h"
10
11 #include <sys/types.h>
12
13 namespace cros_boot_mode {
14
15 PlatformReader::PlatformReader() :
16 value_(kUnsupported), platform_file_path_(NULL) { }
17
18 PlatformReader::~PlatformReader() { }
19
20 const char *PlatformReader::platform_file_path() const {
21 if (platform_file_path_)
22 return platform_file_path_;
23 return default_platform_file_path();
24 }
25
26 void PlatformReader::Initialize() {
27 char *buf = new char[max_size() + 1];
28 size_t bytes_read = helpers::read_file(platform_file_path(),
29 buf,
30 max_size());
31 // read_file doesn't NUL-terminate.
32 buf[bytes_read] = '\0';
33 set_value(Process(buf, bytes_read));
34 delete [] buf;
35 }
36
37 } // namespace cros_boot_mode
OLDNEW
« no previous file with comments | « platform_reader.h ('k') | platform_switch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698