diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-10-18 08:04:47 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-10-18 08:04:47 -0700 |
commit | 875ecaa511ce36c8044ccdf48ee2a3e69dd633fe (patch) | |
tree | 0eee1fac2967ffd3fe711eb56d39e7f1d7f270c8 /core/java/android/os/FileUtils.java | |
parent | dab540e6f8535f6534c08c947c6ccd1d4c43692e (diff) | |
parent | 13e46665ff69c1a37880762d7d611aacdf02dac7 (diff) | |
download | frameworks_base-875ecaa511ce36c8044ccdf48ee2a3e69dd633fe.zip frameworks_base-875ecaa511ce36c8044ccdf48ee2a3e69dd633fe.tar.gz frameworks_base-875ecaa511ce36c8044ccdf48ee2a3e69dd633fe.tar.bz2 |
am 13e46665: am 736f5ec4: Merge "Work on issue #3101415: Crespo apps seem to have their UID changed over time." into gingerbread
Merge commit '13e46665ff69c1a37880762d7d611aacdf02dac7'
* commit '13e46665ff69c1a37880762d7d611aacdf02dac7':
Work on issue #3101415: Crespo apps seem to have their UID changed over time.
Diffstat (limited to 'core/java/android/os/FileUtils.java')
-rw-r--r-- | core/java/android/os/FileUtils.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 72e21de..9d50fd9 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -93,7 +93,22 @@ public class FileUtils * @return volume ID or -1 */ public static native int getFatVolumeId(String mountPoint); - + + /** + * Perform an fsync on the given FileOutputStream. The stream at this + * point must be flushed but not yet closed. + */ + public static boolean sync(FileOutputStream stream) { + try { + if (stream != null) { + stream.getFD().sync(); + } + return true; + } catch (IOException e) { + } + return false; + } + // copy a file from srcFile to destFile, return true if succeed, return // false if fail public static boolean copyFile(File srcFile, File destFile) { @@ -120,7 +135,7 @@ public class FileUtils if (destFile.exists()) { destFile.delete(); } - OutputStream out = new FileOutputStream(destFile); + FileOutputStream out = new FileOutputStream(destFile); try { byte[] buffer = new byte[4096]; int bytesRead; @@ -128,6 +143,11 @@ public class FileUtils out.write(buffer, 0, bytesRead); } } finally { + out.flush(); + try { + out.getFD().sync(); + } catch (IOException e) { + } out.close(); } return true; |