10218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor/*
20218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * Copyright (C) 2010 The Android Open Source Project
30218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor *
40218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * Licensed under the Apache License, Version 2.0 (the "License");
50218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * you may not use this file except in compliance with the License.
60218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * You may obtain a copy of the License at
70218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor *
80218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor *      http://www.apache.org/licenses/LICENSE-2.0
90218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor *
100218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * Unless required by applicable law or agreed to in writing, software
110218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * distributed under the License is distributed on an "AS IS" BASIS,
120218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * See the License for the specific language governing permissions and
140218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * limitations under the License.
150218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor */
160218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
170218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor#ifndef __READ_WRITE_UTILS_H__
180218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor#define __READ_WRITE_UTILS_H__
190218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
20653c657864a436cfa25ecbf2e03fa0ef1eea36f3Rafael Espindola#include <utils/FileMap.h>
210218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor#include <drm/drm_framework_common.h>
224ebd7f54ad9ed6fb64fa2cfbbbebc97dbd30fba6Ted Kremenek
230218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregornamespace android {
24e310d4473ffe22ee8e9161afa56fd8293cf2e013Rafael Espindola
250218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor/**
260218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor * This is an utility class which performs IO operations.
270218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor *
280218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor */
290218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregorclass ReadWriteUtils {
300218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregorpublic:
310218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    /**
320218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * Constructor for ReadWriteUtils
330218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     */
340218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    ReadWriteUtils() {}
350218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
360218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    /**
370218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * Destructor for ReadWriteUtils
385f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner     */
390218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    virtual ~ReadWriteUtils();
400218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
410218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregorpublic:
420218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    /**
435f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner     * Reads the data from the file path provided
440218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     *
450218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @param[in] filePath Path of the file
460218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @return Data read from the file
470218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     */
480218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    static String8 readBytes(const String8& filePath);
490218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    /**
500218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * Reads the data into the given buffer from the file path provided
510218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     *
520218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @param[in] filePath Path of the file
530218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @param[out] buffer Data read from the file
540218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @return Length of the data read from the file
550218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     */
560218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    static int readBytes(const String8& filePath, char** buffer);
570218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    /**
580218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * Writes the data into the file path provided
590218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     *
605f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner     * @param[in] filePath Path of the file
610218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @param[in] dataBuffer Data to write
620218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     */
630218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    static void writeToFile(const String8& filePath, const String8& data);
640218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    /**
650218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * Appends the data into the file path provided
660218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     *
670218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @param[in] filePath Path of the file
680218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     * @param[in] dataBuffer Data to append
690218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor     */
700218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    static void appendToFile(const String8& filePath, const String8& data);
710218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
720218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregorprivate:
730218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor    FileMap* mFileMap;
740218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor};
750218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
760218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor};
770218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
780218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor#endif /* __READ_WRITE_UTILS_H__ */
790218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor
800218936235b137bbdcd29a6c36d61d9215bb4eddDouglas Gregor