from Library.DataType import TAB_SPLIT\r
import Library.DataType as DT\r
from Library.UniClassObject import FormatUniEntry\r
+from Library.String import GetUniFileName\r
\r
def GenPcd(Package, Content):\r
#\r
\r
if not os.path.exists(os.path.dirname(PackageObject.GetFullPath())):\r
os.makedirs(os.path.dirname(PackageObject.GetFullPath()))\r
- ContainerFile = os.path.normpath(os.path.join(os.path.dirname(PackageObject.GetFullPath()), \r
- (PackageObject.GetBaseName() + '.uni')))\r
\r
+ ContainerFile = GetUniFileName(os.path.dirname(PackageObject.GetFullPath()), PackageObject.GetBaseName())\r
+\r
Content = UniFileHeader + '\r\n'\r
Content += '\r\n'\r
\r
#\r
# This file contained the logical of transfer package object to INF files.\r
#\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2016, 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
from Library import DataType as DT\r
from GenMetaFile import GenMetaFileMisc\r
from Library.UniClassObject import FormatUniEntry\r
+from Library.String import GetUniFileName\r
\r
\r
## Transfer Module Object to Inf files\r
return\r
else:\r
ModuleObject.UNIFlag = True\r
- ContainerFile = os.path.normpath(os.path.join(os.path.dirname(ModuleObject.GetFullPath()),\r
- (ModuleObject.GetBaseName() + '.uni')))\r
+ ContainerFile = GetUniFileName(os.path.dirname(ModuleObject.GetFullPath()), ModuleObject.GetBaseName())\r
+\r
if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())):\r
os.makedirs(os.path.dirname(ModuleObject.GetFullPath()))\r
\r
# This file is used to define common string related functions used in parsing\r
# process\r
#\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2016, 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
return True\r
\r
return False\r
+\r
+# Search all files in FilePath to find the FileName with the largest index\r
+# Return the FileName with index +1 under the FilePath\r
+#\r
+def GetUniFileName(FilePath, FileName):\r
+ Files = os.listdir(FilePath)\r
+ LargestIndex = -1\r
+ for File in Files:\r
+ if File.upper().startswith(FileName.upper()) and File.upper().endswith('.UNI'):\r
+ Index = File.upper().replace(FileName.upper(), '').replace('.UNI', '')\r
+ if Index:\r
+ try:\r
+ Index = int(Index)\r
+ except Exception:\r
+ Index = -1\r
+ else:\r
+ Index = 0\r
+ if Index > LargestIndex:\r
+ LargestIndex = Index + 1\r
+\r
+ if LargestIndex > -1:\r
+ return os.path.normpath(os.path.join(FilePath, FileName + str(LargestIndex) + '.uni'))\r
+ else:\r
+ return os.path.normpath(os.path.join(FilePath, FileName + '.uni'))\r