]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / 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 //
37 // Define class members
38 //
39 private static String currentWorkspace = null;
40
41 private static String strWorkspaceDatabaseFile = DataType.FILE_SEPARATOR + "Tools" + DataType.FILE_SEPARATOR
42 + "Conf" + DataType.FILE_SEPARATOR + "FrameworkDatabase.db";
43
44 /**
45
46 @param args
47
48 **/
49 public static void main(String[] args) {
50 // TODO Auto-generated method stub
51
52 }
53
54 /**
55 Get Current Workspace
56
57 @return currentWorkspace
58
59 */
60 public static String getCurrentWorkspace() {
61 return currentWorkspace;
62 }
63
64 /**
65 Set Current Workspace
66
67 @param currentWorkspace
68 The input data of currentWorkspace
69
70 */
71 public static void setCurrentWorkspace(String currentWorkspace) {
72 Workspace.currentWorkspace = currentWorkspace;
73 }
74
75 /**
76 Check if current workspace exists of not
77
78 @retval true - The current WORKSPACE exists
79 @retval false - The current WORKSPACE doesn't exist
80
81 */
82 public static int checkCurrentWorkspace() {
83 return checkWorkspace(getCurrentWorkspace());
84 }
85
86 /**
87 Check if current workspace exists or not via input workspace path
88
89 @param strWorkspace
90 The input data of WORKSPACE path
91 @retval true - The current WORKSPACE exists
92 @retval false - The current WORKSPACE doesn't exist
93
94 */
95 public static int checkWorkspace(String strWorkspace) {
96 //
97 // Check if WORKSPACE Environment is defined
98 //
99 if (strWorkspace == null || strWorkspace == "") {
100 return Workspace.WORKSPACE_NOT_DEFINED;
101 }
102
103 //
104 // Check if WORKSPACE Environment exists
105 //
106 File f = new File(strWorkspace);
107 if (!f.exists()) {
108 return Workspace.WORKSPACE_NOT_EXIST;
109 }
110
111 //
112 // Check if WORKSPACE Environment is a directory
113 //
114 if (!f.isDirectory()) {
115 return Workspace.WORKSPACE_NOT_DIRECTORY;
116 }
117
118 //
119 // Check if FrameworkDatabase.db exists
120 //
121 f = new File(strWorkspace + Workspace.getStrWorkspaceDatabaseFile());
122 if (!f.exists()) {
123 return Workspace.WORKSPACE_NOT_VALID;
124 }
125
126 return Workspace.WORKSPACE_VALID;
127 }
128
129 public static String getStrWorkspaceDatabaseFile() {
130 return strWorkspaceDatabaseFile;
131 }
132
133 public static void setStrWorkspaceDatabaseFile(String strWorkspaceDatabaseFile) {
134 //Workspace.strWorkspaceDatabaseFile = strWorkspaceDatabaseFile;
135 }
136 }