edu.rice.cs.util
Class FileOps.DefaultFileSaver
java.lang.Object
edu.rice.cs.util.FileOps.DefaultFileSaver
- All Implemented Interfaces:
- FileOps.FileSaver
- Enclosing class:
- FileOps
public abstract static class FileOps.DefaultFileSaver
- extends Object
- implements FileOps.FileSaver
This class is a default implementation of FileSaver that makes only one backup of each file per instantiation of
the program (following the Emacs convention). It creates a backup file named ~. It does not implement the
saveTo method.
Method Summary |
void |
backupDone()
This method is called to tell the file saver that a backup was successfully made. |
boolean |
continueWhenTempFileCreationFails()
This method specifies if the saving process should continue trying to save the file if the temp file that is
written initially cannot be created. |
File |
getBackupFile()
This method tells what to name the backup file, if a backup is made. |
File |
getTargetFile()
This method specifies the file for saving. |
boolean |
shouldBackup()
This method indicates whether or not a backup of the file should be made. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileOps.DefaultFileSaver
public FileOps.DefaultFileSaver(File file)
continueWhenTempFileCreationFails
public boolean continueWhenTempFileCreationFails()
- Description copied from interface:
FileOps.FileSaver
- This method specifies if the saving process should continue trying to save the file if the temp file that is
written initially cannot be created. Continue saving in this case is dangerous because the original file may
be lost if saving fails.
- Specified by:
continueWhenTempFileCreationFails
in interface FileOps.FileSaver
getBackupFile
public File getBackupFile()
throws IOException
- Description copied from interface:
FileOps.FileSaver
- This method tells what to name the backup file, if a backup is made. It may depend on getTargetFile(), so it
can throw an IOException.
- Specified by:
getBackupFile
in interface FileOps.FileSaver
- Throws:
IOException
shouldBackup
public boolean shouldBackup()
throws IOException
- Description copied from interface:
FileOps.FileSaver
- This method indicates whether or not a backup of the file should be made. It may depend on getTargetFile(),
so it can throw an IOException.
- Specified by:
shouldBackup
in interface FileOps.FileSaver
- Throws:
IOException
backupDone
public void backupDone()
- Description copied from interface:
FileOps.FileSaver
- This method is called to tell the file saver that a backup was successfully made.
- Specified by:
backupDone
in interface FileOps.FileSaver
getTargetFile
public File getTargetFile()
throws IOException
- Description copied from interface:
FileOps.FileSaver
- This method specifies the file for saving. It should return the canonical name of the file, resolving symlinks.
Otherwise, the saver cannot deal correctly with symlinks. Resolving symlinks may cause an IOException, so this
method declares that it may throw an IOException.
- Specified by:
getTargetFile
in interface FileOps.FileSaver
- Throws:
IOException