aboutsummaryrefslogtreecommitdiff
path: root/catapult/systrace/atrace_helper/jni/file_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'catapult/systrace/atrace_helper/jni/file_utils.h')
-rw-r--r--catapult/systrace/atrace_helper/jni/file_utils.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/catapult/systrace/atrace_helper/jni/file_utils.h b/catapult/systrace/atrace_helper/jni/file_utils.h
index c6a5527e..2b2556bb 100644
--- a/catapult/systrace/atrace_helper/jni/file_utils.h
+++ b/catapult/systrace/atrace_helper/jni/file_utils.h
@@ -39,7 +39,7 @@ ssize_t ReadFile(const char* path, char* buf, size_t length);
// Reads a single-line file, stripping out any \0, \r, \n and replacing
// non-printable charcters with '?'. |buf| is guaranteed to be null terminated.
-bool ReadFileTrimmed(int pid, const char* proc_file, char* buf, size_t length);
+bool ReadFileTrimmed(const char* path, char* buf, size_t length);
// Convenience wrappers for /proc/|pid|/|proc_file| paths.
ssize_t ReadProcFile(int pid, const char* proc_file, char* buf, size_t length);
@@ -48,6 +48,20 @@ bool ReadProcFileTrimmed(int pid,
char* buf,
size_t length);
+// Takes a C string buffer and chunks it into lines without creating any
+// copies. It modifies the original buffer, by replacing \n with \0.
+class LineReader {
+ public:
+ LineReader(char* buf, size_t size);
+ ~LineReader();
+
+ const char* NextLine();
+
+ private:
+ char* ptr_;
+ char* end_;
+};
+
} // namespace file_utils
#endif // FILE_UTILS_H_