sdm: Use fstream to read sysfs entries.

- Replace FILE operations with fstream templates to read sysfs entries.

CRs-Fixed: 1029997
Change-Id: I5603617cbada01a4651394577bed56de38f9f060
diff --git a/sdm/include/utils/sys.h b/sdm/include/utils/sys.h
index ed9b75c..ae75967 100644
--- a/sdm/include/utils/sys.h
+++ b/sdm/include/utils/sys.h
@@ -31,11 +31,22 @@
 #include <stdlib.h>
 #include <poll.h>
 #include <pthread.h>
+#include <fstream>
+
+#ifdef SDM_VIRTUAL_DRIVER
+#include <virtual_driver.h>
+#endif
 
 namespace sdm {
 
 class Sys {
  public:
+#ifndef SDM_VIRTUAL_DRIVER
+  typedef std::fstream fstream;
+#else
+  typedef VirtualFStream fstream;
+#endif
+
   // Pointers to system calls which are either mapped to actual system call or virtual driver.
   typedef int (*ioctl)(int, int, ...);
   typedef int (*open)(const char *, int, ...);
@@ -43,24 +54,20 @@
   typedef int (*poll)(struct pollfd *, nfds_t, int);
   typedef ssize_t (*pread)(int, void *, size_t, off_t);
   typedef ssize_t (*pwrite)(int, const void *, size_t, off_t);
-  typedef FILE* (*fopen)( const char *fname, const char *mode);
-  typedef int (*fclose)(FILE* fileptr);
-  typedef ssize_t (*getline)(char **lineptr, size_t *linelen, FILE *stream);
   typedef int (*pthread_cancel)(pthread_t thread);
   typedef int (*dup)(int fd);
   typedef ssize_t (*read)(int, void *, size_t);
   typedef ssize_t (*write)(int, const void *, size_t);
   typedef int (*eventfd)(unsigned int, int);
 
+  static bool getline_(fstream &fs, std::string &line);  // NOLINT
+
   static ioctl ioctl_;
   static open open_;
   static close close_;
   static poll poll_;
   static pread pread_;
   static pwrite pwrite_;
-  static fopen fopen_;
-  static fclose fclose_;
-  static getline getline_;
   static pthread_cancel pthread_cancel_;
   static dup dup_;
   static read read_;