private State internalReadState(StateImpl toRestore, File stateDirectory, long expectedTimestamp) throws IOException {
File stateFile = new File(stateDirectory, StateReader.STATE_FILE);
File lazyFile = new File(stateDirectory, StateReader.LAZY_FILE);
if (!stateFile.exists() || !lazyFile.exists()) {
StorageManager storageManager = new StorageManager(stateDirectory, "none", true); //$NON-NLS-1$
try {
// if the directory is pointing at the configuration directory then the base files will not exist
storageManager.open(true);
// try using the storage manager to find the managed state files (bug 143255)
File managedState = storageManager.lookup(StateReader.STATE_FILE, false);
File managedLazy = storageManager.lookup(StateReader.LAZY_FILE, false);
if (managedState != null && managedLazy != null) {
stateFile = managedState;
lazyFile = managedLazy;
}
} finally {
storageManager.close();
}
}
StateReader reader = new StateReader(stateFile, lazyFile, false);
if (!reader.loadState(toRestore, expectedTimestamp))
return null;