use of org.eclipse.linuxtools.internal.perf.handlers.PerfSaveStatsHandler in project linuxtools by eclipse.
the class StatData method updateStatData.
/**
* Save latest perf stat result under $workingDirectory/perf.stat. If file
* already exists rename it to perf.old.stat, in order to keep a reference
* to the previous session and be consistent with the way perf handles perf
* report data files.
*/
public void updateStatData() {
// build file name format
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(PerfPlugin.PERF_COMMAND);
// $NON-NLS-1$
stringBuilder.append("%s.");
stringBuilder.append(PerfSaveStatsHandler.DATA_EXT);
String statNameFormat = stringBuilder.toString();
// get current stat file
IPath workingDir = getWorkDir();
// $NON-NLS-1$
String curStatName = String.format(statNameFormat, "");
IPath curStatPath = workingDir.append(curStatName);
IRemoteFileProxy proxy = null;
try {
proxy = RemoteProxyManager.getInstance().getFileProxy(project);
IFileStore curFileStore = proxy.getResource(curStatPath.toOSString());
if (curFileStore.fetchInfo().exists()) {
// get previous stat file
// $NON-NLS-1$
String oldStatName = String.format(statNameFormat, ".old");
IPath oldStatPath = workingDir.append(oldStatName);
IFileStore oldFileStore = proxy.getResource(oldStatPath.toOSString());
if (oldFileStore.fetchInfo().exists()) {
oldFileStore.delete(EFS.NONE, null);
}
curFileStore.copy(oldFileStore, EFS.NONE, null);
curFileStore.delete(EFS.NONE, null);
}
PerfSaveStatsHandler saveStats = new PerfSaveStatsHandler();
saveStats.saveData(PerfPlugin.PERF_COMMAND);
} catch (CoreException e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MsgProxyError, Messages.MsgProxyError);
}
}
Aggregations