]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Library/ParserValidate.py
BaseTool/Upt: Avoid UNI file name conflict
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Library / ParserValidate.py
index 8efb56a61ab1c4aa939a398a87a8b79196f8b6f2..028cf9a54f84cc569397ab5bd590a96653618129 100644 (file)
@@ -1,6 +1,7 @@
 ## @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
@@ -26,6 +27,7 @@ from Library.DataType import TAB_SPACE_SPLIT
 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
@@ -235,7 +237,7 @@ def IsValidPath(Path, Root):
     \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
@@ -286,7 +288,7 @@ def IsValidInstallPath(Path):
         if os.path.isabs(Path):\r
             return False\r
     else:\r
-        if Path[1:2] == ':' or Path.find('\\') >=0:\r
+        if Path[1:2] == ':':\r
             return False\r
         if os.path.isabs(Path):\r
             return False\r
@@ -566,7 +568,7 @@ def IsValidPcdValue(PcdValue):
     for Char in PcdValue:\r
         if Char == '\n' or Char == '\t' or Char == '\f':\r
             return False\r
-        \r
+    \r
     #\r
     # <Boolean>\r
     #\r
@@ -582,7 +584,7 @@ def IsValidPcdValue(PcdValue):
     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
@@ -590,7 +592,6 @@ def IsValidPcdValue(PcdValue):
     if ReIsValidIntegerMulti.match(PcdValue) != None:\r
         return True\r
     \r
-    \r
     #\r
     # <StringVal>              ::=  {<StringType>} {<Array>} {"$(" <MACRO> ")"}\r
     # <StringType>             ::=  {<UnicodeString>} {<CString>}\r
@@ -721,3 +722,12 @@ def IsValidUserId(UserId):
             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