Check USB Content
I have developed an C++ algorithm, which saves the contents of 开发者_运维百科a USB key in a database. In the Database, as well as save the file names are saved on the USB device info: free blocks and vendors. So when I put more control keys free blocks. If the comparison were to change, the database must be recreated. So if I remove or add files to the USB key, the database is rebuilt from scratch. But when I rename a file, nothing happens. You can find out the changes without having to check each file in the database?
How can I better control of the entire contents of a USB device? Some help!
Thanks!
P.s.: I used ioctl for vendor name and free blocks!!
You could create a hash value from the folder file listing and store that in your DB.
Each time the USB stick is inserted perform the hash calculation of the folder listing and compare to the value stored. If they are different you can assume files have been removed, added or renamed and perform a refresh of your DB.
If you control the OS and the USB key, you can use NTFS. It has a change log feature. This contains an Update Sequence Number (USN). Any change to the key will change the USN. So, you only need to save the old value in your database. If you see a new value, reread the whole file system and update the USN in your database.
精彩评论