summaryrefslogtreecommitdiff
path: root/base/android/java/src/org/chromium/base/ImportantFileWriterAndroid.java
blob: cbaf7f76a169af90fc50aa015d949e48f17916a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.base;

import org.chromium.base.annotations.JNINamespace;

/**
 * This class provides an interface to the native class for writing
 * important data files without risking data loss.
 */
@JNINamespace("base::android")
public class ImportantFileWriterAndroid {

    /**
     * Write a binary file atomically.
     *
     * This either writes all the data or leaves the file unchanged.
     *
     * @param fileName The complete path of the file to be written
     * @param data The data to be written to the file
     * @return true if the data was written to the file, false if not.
     */
    public static boolean writeFileAtomically(String fileName, byte[] data) {
        return nativeWriteFileAtomically(fileName, data);
    }

    private static native boolean nativeWriteFileAtomically(
            String fileName, byte[] data);
}