(File fileName)
| 326 | } |
| 327 | |
| 328 | public static void fsyncAll(File fileName) throws IOException { |
| 329 | Stack<File> filesStack = new Stack<>(); |
| 330 | filesStack.push(fileName); |
| 331 | while (!filesStack.isEmpty()) { |
| 332 | File currentFile = filesStack.pop(); |
| 333 | if (currentFile.isDirectory()) { |
| 334 | File[] fileList = currentFile.listFiles(); |
| 335 | if (fileList == null) { |
| 336 | throw new IOException("cannot list directory " + currentFile); |
| 337 | } |
| 338 | for (File entry : fileList) { |
| 339 | filesStack.push(entry); |
| 340 | } |
| 341 | } else if (!currentFile.getPath().endsWith("_lock")) { |
| 342 | // Do not sync! Any close(2) of a locked file counts as releasing the file for the whole |
| 343 | // process! |
| 344 | try (RandomAccessFile file = new RandomAccessFile(currentFile, "r")) { |
| 345 | file.getFD().sync(); |
| 346 | } catch (IOException e) { |
| 347 | LogUtil.e(TAG, "Syncing failed for " + currentFile + ": " + e.getMessage()); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | private static long getParcelPadSize(long len) { |
| 354 | return len + (4 - (len % 4)) % 4; |
no test coverage detected