Top Fields Constructors Methods
org.jabref.logic.util.io

public Class BackupFileUtil

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.file.Files, .Path, java.time.ZonedDateTime, java.time.format.DateTimeFormatter, java.util.HexFormat, .Optional, org.jabref.gui.autosaveandbackup.BackupManager, org.jabref.logic.util.BackupFileType, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Path
getPathForNewBackupFileAndCreateDirectory(Path targetFile, BackupFileType fileType, Path backupDir)

Determines the path of the backup file (using the given extension)

As default, a directory inside the user temporary dir is used.

public static Optional<Path>
getPathOfLatestExistingBackupFile(Path targetFile, BackupFileType fileType, Path backupDir)

public static String
getUniqueFilePrefix(Path targetFile)

Determines a unique file prefix.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

BackupFileUtilback to summary
private BackupFileUtil()

Method Detail

getPathForNewBackupFileAndCreateDirectoryback to summary
public static Path getPathForNewBackupFileAndCreateDirectory(Path targetFile, BackupFileType fileType, Path backupDir)

Determines the path of the backup file (using the given extension)

As default, a directory inside the user temporary dir is used.
In case a AUTOSAVE backup is requested, a timestamp is added

SIDE EFFECT: Creates the directory. In case that fails, the return path of the .bak file is set to be next to the .bib file

Note that this backup is different from the .sav file generated by BackupManager (and configured in the preferences as "make backups")

getPathOfLatestExistingBackupFileback to summary
public static Optional<Path> getPathOfLatestExistingBackupFile(Path targetFile, BackupFileType fileType, Path backupDir)
getUniqueFilePrefixback to summary
public static String getUniqueFilePrefix(Path targetFile)

Determines a unique file prefix.

When creating a backup file, the backup file should belong to the original file. Just adding ".bak" suffix to the filename, does not work in all cases: It may be possible that the user has opened "paper.bib" twice. Thus, we need to create a unique prefix to distinguish these files.