## @file ParserValidate.py\r
+# Functions for parser validation\r
#\r
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available \r
# under the terms and conditions of the BSD License which accompanies this \r
\r
import os.path\r
import re\r
+import platform\r
\r
from Library.DataType import MODULE_LIST\r
from Library.DataType import COMPONENT_TYPE_LIST\r
from Library.String import GetSplitValueList\r
from Library.ExpressionValidate import IsValidBareCString\r
from Library.ExpressionValidate import IsValidFeatureFlagExp\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
\r
## __HexDigit() method\r
#\r
\r
Path = os.path.normpath(Path).replace('\\', '/')\r
Root = os.path.normpath(Root).replace('\\', '/')\r
- FullPath = os.path.normpath(os.path.join(Root, Path)).replace('\\', '/')\r
+ FullPath = mws.join(Root, Path)\r
\r
if not os.path.exists(FullPath):\r
return False\r
# @param Path: path to be checked\r
#\r
def IsValidInstallPath(Path):\r
- if os.path.isabs(Path):\r
- return False\r
- \r
+ if platform.platform().find("Windows") >= 0:\r
+ if os.path.isabs(Path):\r
+ return False\r
+ else:\r
+ if Path[1:2] == ':':\r
+ return False\r
+ if os.path.isabs(Path):\r
+ return False\r
if Path.startswith('.'):\r
return False\r
\r
for Char in PcdValue:\r
if Char == '\n' or Char == '\t' or Char == '\f':\r
return False\r
- \r
+ \r
#\r
# <Boolean>\r
#\r
if IsValidHex(PcdValue):\r
return True\r
\r
- ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL) \r
+ ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL)\r
if ReIsValidIntegerSingle.match(PcdValue) != None:\r
return True\r
\r
if ReIsValidIntegerMulti.match(PcdValue) != None:\r
return True\r
\r
- \r
#\r
# <StringVal> ::= {<StringType>} {<Array>} {"$(" <MACRO> ")"}\r
# <StringType> ::= {<UnicodeString>} {<CString>}\r
return False\r
return True\r
\r
+#\r
+# Check if a UTF16-LE file has a BOM header\r
+#\r
+def CheckUTF16FileHeader(File):\r
+ FileIn = open(File, 'rb').read(2)\r
+ if FileIn != '\xff\xfe':\r
+ return False\r
+\r
+ return True\r