blob: 529b3424571bf310b82ffd63493d922a64c44d48 [file] [log] [blame]
aimitakeshi27ed8ad2010-07-29 10:12:27 +09001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __READ_WRITE_UTILS_H__
18#define __READ_WRITE_UTILS_H__
19
20#include <utils/FileMap.h>
21#include <drm/drm_framework_common.h>
22
23namespace android {
24
25/**
26 * This is an utility class which performs IO operations.
27 *
28 */
29class ReadWriteUtils {
30public:
31 /**
32 * Constructor for ReadWriteUtils
33 */
34 ReadWriteUtils() {}
35
36 /**
37 * Destructor for ReadWriteUtils
38 */
39 virtual ~ReadWriteUtils();
40
41public:
42 /**
43 * Reads the data from the file path provided
44 *
45 * @param[in] filePath Path of the file
46 * @return Data read from the file
47 */
48 static String8 readBytes(const String8& filePath);
49 /**
Takeshi Aimi2272ee22010-09-20 23:40:41 +090050 * Reads the data into the given buffer from the file path provided
51 *
52 * @param[in] filePath Path of the file
53 * @param[out] buffer Data read from the file
54 * @return Length of the data read from the file
55 */
56 static int readBytes(const String8& filePath, char** buffer);
57 /**
aimitakeshi27ed8ad2010-07-29 10:12:27 +090058 * Writes the data into the file path provided
59 *
60 * @param[in] filePath Path of the file
61 * @param[in] dataBuffer Data to write
62 */
63 static void writeToFile(const String8& filePath, const String8& data);
64 /**
65 * Appends the data into the file path provided
66 *
67 * @param[in] filePath Path of the file
68 * @param[in] dataBuffer Data to append
69 */
70 static void appendToFile(const String8& filePath, const String8& data);
71
72private:
73 FileMap* mFileMap;
74};
75
76};
77
78#endif /* __READ_WRITE_UTILS_H__ */
79