docs: private void writeToFile(MemoryCommitResult mcr) {
          // Rename the current file so it may be used as a backup during the next read
          if (mFile.exists()) {
              if (!mcr.changesMade) {
                  // If the file already exists, but no changes were
                  // made to the underlying map, it's wasteful to
                  // re-write the file.  Return as if we wrote it
                  // out.
                  mcr.setDiskWriteResult(true);
                  return;
              }
              if (!mBackupFile.exists()) {
                  if (!mFile.renameTo(mBackupFile)) {
                      System.out.println( "Couldn't rename file " + mFile
                              + " to backup file " + mBackupFile);
                      mcr.setDiskWriteResult(false);
                      return;
                  }
              } else {
                  mFile.delete();
              }
          }
  
          // Attempt to write the file, delete the backup and return true as atomically as
          // possible.  If any exception occurs, delete the new file; next time we will restore
          // from the backup.
          try {
              FileOutputStream str = createFileOutputStream(mFile);
              if (str == null) {
                  mcr.setDiskWriteResult(false);
                  return;
              }
              XmlUtils.writeMapXml(mcr.mapToWriteToDisk, str);
              FileUtils.sync(str);
              str.close();
              setFilePermissionsFromMode(mFile.getPath(), mMode, 0);
              if (mFile.canRead()) {
                  synchronized (this) {
                      mStatTimestamp = mFile.lastModified();
                      mStatSize = mFile.length();
                  }
              }
              // Writing was successful, delete the backup file if there is one.
              mBackupFile.delete();
              mcr.setDiskWriteResult(true);
              return;
          } catch (IOException e) {
              System.out.println("writeToFile: Got exception:" + e);
          }
          // Clean up an unsuccessfully written file
          if (mFile.exists()) {
              if (!mFile.delete()) {
                  System.out.println("Couldn't clean up partially-written file " + mFile);
              }
          }
          mcr.setDiskWriteResult(false);
      }