I am making a protocol, client, and server that provide file transfer functions similar to FTP (among other functions). One difference between my protocol and FTP is that I would like to keep a copy of the remote server's directory structure in the local cache. The server will only work on Windows (written in C ++), so any applicable Win32 API calls will be evaluated (if any). At the initial connection, the client requests immediate children (both files and directories, as well as "ls" or "dir" without parameters), and then, when the user goes to the directory, this step is repeated with a new parent, as you might expect.
Of course, most of the time, if the same directory of a given server is requested twice by the client, the contents of the directory will be the same. Therefore, I would like to cache the results of each directory listing on the client. I would like a simple way to implement this, but it will have to take into account expiring cache elements due to access to files / directories, change time and name, which is the difficult part. Ideally, I would like something that would allow almost instant directory listings by the client, with something like a hash that would take into account not only the contents of the file, but also changes in the contents of subdirectory files, data dates, changes and access dates, etc. .d.
This is NOT something that can rely entirely on FileSystemWatcher objects (or similar), because it will need to support this cache, even if the program only starts occasionally. Of course, it would be nice to help maintain the cache, but this is only part of the problem.
My best (?) Idea so far is using FindFirstFile () and FindNextFile () and sorting (somehow), concatenation and hashing found in WIN32_FIND_DATA structures (possibly the contents of the file), and using this as a token for expiration (only to indicate a change in any of these fields). Then I will have one of these tokens for each directory. When a directory is requested, the server will hash everything and compare it with the cached hash provided by the client, and if it is different, return normal data, otherwise the equivalent of HTTP 304. Is there a less complicated way to do something like this? Does the "Last Modified Directory Date" take into account each of the modification dates of the subdirectory files under any circumstances? I'm sure the built-in windows indexing service has something like this,but ideally, I would not have to rely on her.
, -, , , , , , .
, , , , (rsync subversion , ).