]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java
580086ff92b718367f5219343db992d6bb5bd995
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / workspace / Workspace.java
1 /** @file
2
3 The file is used to init workspace
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 package org.tianocore.frameworkwizard.workspace;
17
18 import java.io.File;
19
20 import org.tianocore.frameworkwizard.common.DataType;
21
22 public class Workspace {
23 //
24 // Define static return value
25 //
26 public final static int WORKSPACE_VALID = 0;
27
28 public final static int WORKSPACE_NOT_DEFINED = 1;
29
30 public final static int WORKSPACE_NOT_EXIST = 2;
31
32 public final static int WORKSPACE_NOT_DIRECTORY = 3;
33
34 public final static int WORKSPACE_NOT_VALID = 4;
35
36 public final static int WORKSPACE_NO_TARGET_FILE = 5;
37
38 //
39 // Define class members
40 //
41 private static String currentWorkspace = null;
42
43 private static String strWorkspaceDatabaseFile = DataType.FILE_SEPARATOR + "Tools" + DataType.FILE_SEPARATOR
44 + "Conf" + DataType.FILE_SEPARATOR + "FrameworkDatabase.db";
45
46 private static String targetFile = DataType.FILE_SEPARATOR + "Tools" + DataType.FILE_SEPARATOR + "Conf"
47 + DataType.FILE_SEPARATOR + "target.txt";
48
49 /**
50
51 @param args
52
53 **/
54 public static void main(String[] args) {
55 // TODO Auto-generated method stub
56
57 }
58
59 /**
60 Get Current Workspace
61
62 @return currentWorkspace
63
64 */
65 public static String getCurrentWorkspace() {
66 return currentWorkspace;
67 }
68
69 /**
70 Set Current Workspace
71
72 @param currentWorkspace
73 The input data of currentWorkspace
74
75 */
76 public static void setCurrentWorkspace(String currentWorkspace) {
77 Workspace.currentWorkspace = currentWorkspace;
78 }
79
80 /**
81 Check if current workspace exists of not
82
83 @retval true - The current WORKSPACE exists
84 @retval false - The current WORKSPACE doesn't exist
85
86 */
87 public static int checkCurrentWorkspace() {
88 return checkWorkspace(getCurrentWorkspace());
89 }
90
91 /**
92 Check if current workspace exists or not via input workspace path
93
94 @param strWorkspace
95 The input data of WORKSPACE path
96 @retval true - The current WORKSPACE exists
97 @retval false - The current WORKSPACE doesn't exist
98
99 */
100 public static int checkWorkspace(String strWorkspace) {
101 //
102 // Check if WORKSPACE Environment is defined
103 //
104 if (strWorkspace == null || strWorkspace == "") {
105 return Workspace.WORKSPACE_NOT_DEFINED;
106 }
107
108 //
109 // Check if WORKSPACE Environment exists
110 //
111 File f = new File(strWorkspace);
112 if (!f.exists()) {
113 return Workspace.WORKSPACE_NOT_EXIST;
114 }
115
116 //
117 // Check if WORKSPACE Environment is a directory
118 //
119 if (!f.isDirectory()) {
120 return Workspace.WORKSPACE_NOT_DIRECTORY;
121 }
122
123 //
124 // Check if FrameworkDatabase.db exists
125 //
126 f = new File(strWorkspace + Workspace.getStrWorkspaceDatabaseFile());
127 if (!f.exists()) {
128 return Workspace.WORKSPACE_NOT_VALID;
129 }
130
131 //
132 // Check if Target.txt exists
133 //
134 f = new File(strWorkspace + Workspace.getTargetFile());
135 if (!f.exists()) {
136 return Workspace.WORKSPACE_NO_TARGET_FILE;
137 }
138
139 return Workspace.WORKSPACE_VALID;
140 }
141
142 public static String getStrWorkspaceDatabaseFile() {
143 return strWorkspaceDatabaseFile;
144 }
145
146 public static void setStrWorkspaceDatabaseFile(String strWorkspaceDatabaseFile) {
147 //Workspace.strWorkspaceDatabaseFile = strWorkspaceDatabaseFile;
148 }
149
150 public static String getTargetFile() {
151 return targetFile;
152 }
153 }