3 The file is used to init workspace
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
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.
16 package org
.tianocore
.frameworkwizard
.workspace
;
20 import org
.tianocore
.frameworkwizard
.common
.DataType
;
22 public class Workspace
{
24 // Define static return value
26 public final static int WORKSPACE_VALID
= 0;
28 public final static int WORKSPACE_NOT_DEFINED
= 1;
30 public final static int WORKSPACE_NOT_EXIST
= 2;
32 public final static int WORKSPACE_NOT_DIRECTORY
= 3;
34 public final static int WORKSPACE_NOT_VALID
= 4;
36 public final static int WORKSPACE_NO_TARGET_FILE
= 5;
39 // Define class members
41 private static String currentWorkspace
= null;
43 private static String strWorkspaceDatabaseFile
= DataType
.FILE_SEPARATOR
+ "Tools" + DataType
.FILE_SEPARATOR
44 + "Conf" + DataType
.FILE_SEPARATOR
+ "FrameworkDatabase.db";
46 private static String targetFile
= DataType
.FILE_SEPARATOR
+ "Tools" + DataType
.FILE_SEPARATOR
+ "Conf"
47 + DataType
.FILE_SEPARATOR
+ "target.txt";
54 public static void main(String
[] args
) {
55 // TODO Auto-generated method stub
62 @return currentWorkspace
65 public static String
getCurrentWorkspace() {
66 return currentWorkspace
;
72 @param currentWorkspace
73 The input data of currentWorkspace
76 public static void setCurrentWorkspace(String currentWorkspace
) {
77 Workspace
.currentWorkspace
= currentWorkspace
;
81 Check if current workspace exists of not
83 @retval true - The current WORKSPACE exists
84 @retval false - The current WORKSPACE doesn't exist
87 public static int checkCurrentWorkspace() {
88 return checkWorkspace(getCurrentWorkspace());
92 Check if current workspace exists or not via input workspace path
95 The input data of WORKSPACE path
96 @retval true - The current WORKSPACE exists
97 @retval false - The current WORKSPACE doesn't exist
100 public static int checkWorkspace(String strWorkspace
) {
102 // Check if WORKSPACE Environment is defined
104 if (strWorkspace
== null || strWorkspace
== "") {
105 return Workspace
.WORKSPACE_NOT_DEFINED
;
109 // Check if WORKSPACE Environment exists
111 File f
= new File(strWorkspace
);
113 return Workspace
.WORKSPACE_NOT_EXIST
;
117 // Check if WORKSPACE Environment is a directory
119 if (!f
.isDirectory()) {
120 return Workspace
.WORKSPACE_NOT_DIRECTORY
;
124 // Check if FrameworkDatabase.db exists
126 f
= new File(strWorkspace
+ Workspace
.getStrWorkspaceDatabaseFile());
128 return Workspace
.WORKSPACE_NOT_VALID
;
132 // Check if Target.txt exists
134 f
= new File(strWorkspace
+ Workspace
.getTargetFile());
136 return Workspace
.WORKSPACE_NO_TARGET_FILE
;
139 return Workspace
.WORKSPACE_VALID
;
142 public static String
getStrWorkspaceDatabaseFile() {
143 return strWorkspaceDatabaseFile
;
146 public static void setStrWorkspaceDatabaseFile(String strWorkspaceDatabaseFile
) {
147 //Workspace.strWorkspaceDatabaseFile = strWorkspaceDatabaseFile;
150 public static String
getTargetFile() {