added creation date and a simple hash on the file name for to improve the uniqueness...
authorSimon Brandner <simon.brandner@partner.bmw.de>
Thu, 21 Mar 2013 13:29:33 +0000 (14:29 +0100)
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 19 Jul 2013 14:54:32 +0000 (16:54 +0200)
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
src/lib/dlt_filetransfer.c

index d690696..ce18f52 100644 (file)
@@ -77,6 +77,30 @@ unsigned long getFilesize(const char* file){
        return (unsigned long)st.st_size;
 }
 
+/** A simple Hash function for C-strings
+ * @param str input string. E.g. a file path.
+ * @param hash start and result value for hash computation
+ *
+ */
+void stringHash(const char* str, unsigned long *hash )
+{
+    if (!str || !hash)
+        return;
+   unsigned int len = strlen(str);
+
+   unsigned int i = 0;
+   if (len <= 0){
+    return;
+   }
+
+   for(i = 0; i < len;  i++)
+   {
+      *hash = 53 * *hash  + str[i];
+   }
+
+}
+
+
 //!Get some information about the file serial number of a file
 /** See stat(2) for more informations.
  * @param file Absolute file path
@@ -89,6 +113,8 @@ unsigned long getFileSerialNumber(const char* file){
        ret = st.st_ino;
        ret = ret << (sizeof(ret)*8)/2;
        ret |= st.st_size;
+    ret ^= st.st_ctime;
+    stringHash(file, &ret);
        return ret;
 }