~ubuntu-branches/ubuntu/utopic/thermald/utopic

« back to all changes in this revision

Viewing changes to .pc/0012-Prevent-exception-for-invalid-sysfs-file-reads.patch/src/thd_sys_fs.h

  • Committer: Package Import Robot
  • Author(s): Colin King
  • Date: 2014-05-19 12:41:22 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140519124122-zan11arvjxtbqcq5
Tags: 1.2-1
* Adjust for coretemp path change
* Deny non root users to send system bus dbus messages
* Remove compile warning
* Remove rpmlint warning for manual page
* Remove old patches that are now included into version 1.2
* Sync up with version 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * thd_sys_fs.h: sysfs class interface
3
 
 *
4
 
 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public License version
8
 
 * 2 or later as published by the Free Software Foundation.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
 
 * 02110-1301, USA.
19
 
 *
20
 
 *
21
 
 * Author Name <Srinivas.Pandruvada@linux.intel.com>
22
 
 *
23
 
 */
24
 
 
25
 
#ifndef THD_SYS_FS_H_
26
 
#define THD_SYS_FS_H_
27
 
 
28
 
#include <sys/types.h>
29
 
#include <sys/stat.h>
30
 
#include <fcntl.h>
31
 
#include <unistd.h>
32
 
#include <errno.h>
33
 
#include <fstream>
34
 
#include <iostream>
35
 
#include <sstream>
36
 
#include <string>
37
 
 
38
 
class csys_fs {
39
 
private:
40
 
        std::string base_path;
41
 
 
42
 
public:
43
 
        csys_fs() :
44
 
                        base_path("") {
45
 
        }
46
 
        ;
47
 
        csys_fs(const char *path) :
48
 
                        base_path(path) {
49
 
        }
50
 
 
51
 
        /* write data to base path (dir) + provided path */
52
 
        int write(const std::string &path, const std::string &buf);
53
 
        int write(const std::string &path, unsigned int data);
54
 
        int write(const std::string &path, unsigned int position,
55
 
                        unsigned long long data);
56
 
 
57
 
        /* read data from base path (dir) + provided path */
58
 
        int read(const std::string &path, char *buf, int len);
59
 
        int read(const std::string &path, std::string &buf);
60
 
        int read(const std::string &path, unsigned int *ptr_val);
61
 
        int read(const std::string &path, unsigned int position, char *buf,
62
 
                        int len);
63
 
 
64
 
        const char *get_base_path() {
65
 
                return base_path.c_str();
66
 
        }
67
 
        int read_symbolic_link_value(const std::string &path, char *buf, int len);
68
 
 
69
 
        bool exists(const std::string &path);
70
 
        bool exists();
71
 
 
72
 
        void update_path(std::string path) {
73
 
                base_path = path;
74
 
        }
75
 
};
76
 
 
77
 
#endif /* THD_SYS_FS_H_ */