Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Internal change #173

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;

/** Applies patches. */
public class FileByFileDeltaApplier extends DeltaApplier {
Expand Down Expand Up @@ -68,7 +69,7 @@ public void applyDelta(ByteSource oldBlob, InputStream deltaIn, OutputStream new
// will fail when it tries to create the file in a few more lines anyways.
tempDir.mkdirs();
}
File tempFile = File.createTempFile("gfbfv1", "old", tempDir);
File tempFile = Files.createTempFile(tempDir.toPath(), "gfbfv1", "old").toFile();
try {
applyDeltaInternal(oldBlob, tempFile, deltaIn, newBlobOut);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;

/**
* A closeable container for a temp blob that deletes itself on {@link #close()}. This is convenient
Expand Down Expand Up @@ -157,7 +158,7 @@ protected void finalize() {
}

private void createNewFile() throws IOException {
file = File.createTempFile("archive_patcher", "tmp");
file = Files.createTempFile("archive_patcher", "tmp").toFile();
file.deleteOnExit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Files;

// TODO: clean up the implementations, we only really need two and they can be in
// separate files.
Expand Down Expand Up @@ -389,7 +390,7 @@ public RandomAccessMmapObject(final String tempFileName, final String mode, long
"RandomAccessMmapObject only supports file sizes up to " + "Integer.MAX_VALUE.");
}

mFile = File.createTempFile(tempFileName, "temp");
mFile = Files.createTempFile(tempFileName, "temp").toFile();
mFile.deleteOnExit();
mShouldDeleteFileOnRelease = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import com.google.archivepatcher.generator.bsdiff.RandomAccessObject.RandomAccessByteArrayObject;
import com.google.archivepatcher.generator.bsdiff.RandomAccessObject.RandomAccessFileObject;
import com.google.archivepatcher.generator.bsdiff.RandomAccessObject.RandomAccessMmapObject;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.file.Files;

/**
* A factory for creating instances of {@link RandomAccessObject}. BsDiff needs to store some
Expand Down Expand Up @@ -59,7 +59,7 @@ public RandomAccessFileObjectFactory(String mode) {
@Override
public RandomAccessObject create(int size) throws IOException {
return new RandomAccessObject.RandomAccessFileObject(
File.createTempFile(FILE_NAME_PREFIX, "temp"), mMode, true);
Files.createTempFile(FILE_NAME_PREFIX, "temp").toFile(), mMode, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -225,7 +226,7 @@ public static void generatePatch(
*/
public static void applyPatch(File oldFile, File patchFile, File newFile) throws IOException {
// Figure out temp directory
File tempFile = File.createTempFile("fbftool", "tmp");
File tempFile = Files.createTempFile("fbftool", "tmp").toFile();
File tempDir = tempFile.getParentFile();
tempFile.delete();
FileByFileDeltaApplier applier = new FileByFileDeltaApplier(tempDir);
Expand Down