]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Table/TableFile.py
BaseTools: Replace StandardError with Expression
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableFile.py
index 86dddd0f2b63dbd05e572fb417e8bec4ca38a4eb..ac762ea7fcc01c7f98e05a0a44a9863561c9f534 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create/update/query/erase table for files\r
 #\r
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,8 +16,8 @@
 #\r
 import Common.EdkLogger as EdkLogger\r
 from Table import Table\r
-from Common.String import ConvertToSqlString\r
-import os\r
+from Common.StringUtils import ConvertToSqlString\r
+import Common.LongFilePathOs as os\r
 from CommonDataClass.DataClass import FileClass\r
 \r
 ## TableFile\r
@@ -89,3 +89,16 @@ class TableFile(Table):
         TimeStamp = os.stat(FileFullPath)[8]\r
         File = FileClass(-1, Name, Ext, Filepath, FileFullPath, Model, '', [], [], [])\r
         return self.Insert(File.Name, File.ExtName, File.Path, File.FullPath, File.Model, TimeStamp)\r
+    \r
+    ## Get ID of a given file\r
+    #\r
+    #   @param  FilePath    Path of file\r
+    #\r
+    #   @retval ID          ID value of given file in the table\r
+    #\r
+    def GetFileId(self, File):\r
+        QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))\r
+        RecordList = self.Exec(QueryScript)\r
+        if len(RecordList) == 0:\r
+            return None\r
+        return RecordList[0][0]\r