• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.base;
6 
7 import org.chromium.base.annotations.JNINamespace;
8 
9 /**
10  * This class provides an interface to the native class for writing
11  * important data files without risking data loss.
12  */
13 @JNINamespace("base::android")
14 public class ImportantFileWriterAndroid {
15 
16     /**
17      * Write a binary file atomically.
18      *
19      * This either writes all the data or leaves the file unchanged.
20      *
21      * @param fileName The complete path of the file to be written
22      * @param data The data to be written to the file
23      * @return true if the data was written to the file, false if not.
24      */
writeFileAtomically(String fileName, byte[] data)25     public static boolean writeFileAtomically(String fileName, byte[] data) {
26         return nativeWriteFileAtomically(fileName, data);
27     }
28 
nativeWriteFileAtomically( String fileName, byte[] data)29     private static native boolean nativeWriteFileAtomically(
30             String fileName, byte[] data);
31 }
32