private synchronized State refresh() { final long mtime = configFile.lastModified(); if (mtime != lastModified) { State newState = new State(); try (BufferedReader br = Files .newBufferedReader(configFile.toPath(), UTF_8)) { newState.entries = parse(br); } catch (IOException | RuntimeException none) { // Ignore -- we'll set and return an empty state } lastModified = mtime; state = newState; } return state; }
private synchronized State refresh() { final long mtime = configFile.lastModified(); if (mtime != lastModified) { State newState = new State(); try (BufferedReader br = Files .newBufferedReader(configFile.toPath(), UTF_8)) { newState.entries = parse(br); } catch (IOException | RuntimeException none) { // Ignore -- we'll set and return an empty state } lastModified = mtime; state = newState; } return state; }
/** * Creates a new {@link OpenSshConfigFile} that will read the config from * file {@code config} use the given file {@code home} as "home" directory. * * @param home * user's home directory for the purpose of ~ replacement * @param config * file to load. * @param localUserName * user name of the current user on the local host OS */ public OpenSshConfigFile(@NonNull File home, @NonNull File config, @NonNull String localUserName) { this.home = home; this.configFile = config; this.localUserName = localUserName; state = new State(); }
/** * Creates a new {@link OpenSshConfigFile} that will read the config from * file {@code config} use the given file {@code home} as "home" directory. * * @param home * user's home directory for the purpose of ~ replacement * @param config * file to load. * @param localUserName * user name of the current user on the local host OS */ public OpenSshConfigFile(@NonNull File home, @NonNull File config, @NonNull String localUserName) { this.home = home; this.configFile = config; this.localUserName = localUserName; state = new State(); }