Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I convert a directory path to a unique numerical identifier (Linux/C++)?
    primarykey
    data
    text
    <p>I am investigating ways to take a directory (folder) and derive some form of unique numerical identifier. I have investigated "string to hash" methods, however, the <a href="http://www.codinghorror.com/blog/2007/12/hashtables-pigeonholes-and-birthdays.html" rel="nofollow">Pigeon Hole Principle</a> means that one can never derive a truely unique number for every single string.</p> <p>String to unique hash is no good.</p> <p>I have recently been investigating other means of achieving my goal and thus have the following question to ask:</p> <p><strong>Directory time stamps - how 'unique' are they?</strong> To what resolution are the time stamps reported by 'stat' as described <a href="http://www.linuxquestions.org/questions/programming-9/how-to-get-directory-time-stamp-in-c-719347/" rel="nofollow">here</a> (second post)? if the resolution is small enough, is it possible for more than one folder to share the exact same time stamp on a Linux system?</p> <p>If anyone has other methods/techniques they'd like to share, I'd be happy to listen :)</p> <p><strong>Edit 1</strong> To clarify my use case in response to the answers posted so far: I am working on Android platforms, so the filesystem is not linked to any other (except of course for removeable media such as Micro SD cards).</p> <p>I am inserting each path into a database but trying to avoid string comparisons when querying the table. The use of maps/hashmaps is not an option here. Yes, the path itself is unique, but ideally I need a numerical identifier that can be used to query the table as opposed to the path itself. The identifier must also be unique per path. I have experimented with std::collate but found there were many collides in the hashes (a dataset of 20, 000 paths yeilds approximatley 100 collides). What was even more surprising is that the hashes appeared to be largely different each time my application is run. I wonder if it's seeded somehow?</p> <p>Many thanks, P</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload