# Return the FileName with index +1 under the FilePath\r
#\r
def GetUniFileName(FilePath, FileName):\r
- Files = os.listdir(FilePath)\r
+ Files = []\r
+ try:\r
+ Files = os.listdir(FilePath)\r
+ except:\r
+ pass\r
+\r
LargestIndex = -1\r
+ IndexNotFound = True\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
except Exception:\r
Index = -1\r
else:\r
+ IndexNotFound = False\r
Index = 0\r
if Index > LargestIndex:\r
LargestIndex = Index + 1\r
\r
- if LargestIndex > -1:\r
+ if LargestIndex > -1 and not IndexNotFound:\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