Commit | Line | Data |
---|---|---|
f4da4c59 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
12 | package org.eclipse.tracecompass.internal.lttng2.control.core; | |
13 | ||
14 | import java.io.File; | |
15 | ||
16 | import org.eclipse.core.runtime.IPath; | |
17 | ||
18 | /** | |
19 | * Class to manage LTTng profiles files in workspace. | |
20 | * | |
21 | * @author Bernd Hufmann | |
22 | */ | |
23 | public class LttngProfileManager { | |
24 | ||
25 | private static final String FOLDER = "sessions"; //$NON-NLS-1$ | |
26 | ||
27 | private static final IPath SAVED_PROFILE_PATH = | |
28 | Activator.getDefault().getStateLocation().append(FOLDER); | |
29 | ||
30 | static { | |
31 | File dir = SAVED_PROFILE_PATH.toFile(); | |
32 | /* Check if directory exists, otherwise create it */ | |
33 | if (!dir.exists() || !dir.isDirectory()) { | |
34 | dir.mkdirs(); | |
35 | } | |
36 | } | |
37 | ||
38 | /** | |
39 | * Returns all LTTng profile files available in workspace. | |
40 | * | |
41 | * @return array with LTTng profiles | |
42 | */ | |
43 | public static File[] getProfiles() { | |
44 | return SAVED_PROFILE_PATH.toFile().listFiles(); | |
45 | } | |
fc9ff6c4 BH |
46 | |
47 | /** | |
48 | * Gets the path where the profiles are located in the workspace. | |
49 | * | |
50 | * @return the profile path | |
51 | */ | |
52 | public static IPath getProfilePath() { | |
53 | return SAVED_PROFILE_PATH; | |
54 | } | |
f4da4c59 | 55 | } |