You have my full permission to implement this project any way you please.
I often run bulk processes on files such as:
This will save, for example, spuriouly uploading unchanged files to my website. It will also give me accurate dates a when file content was actually changed.
Every time you run the utility, it recomputes the digests for each file. If they match, it sets the file back to the old date. If they don’t it notes the new timestamp and digest in the people/seal/untouch.digest file.
Tests for file equality compare the file length, then if that matches compare the digest. You don’t need to recompute digests for files whose lengths have not changed or dates have not changed.
It deals with new files and deleted files in the obvious way.
As an add on feature, redate the files back, whether they match or not. This lets you preserve the old dates when there have only been cosmetic changes.
The trickiest part of this project is writing the tiny piece of JNI (Java Native Interface) code to set the date on a file. Unfortunately, this is not supported in pure Java.
You need first to get a handle to the file with the Window’s API (Application Programming Interface) CreateFile. This function is misnamed. It does not create a file; it creates a file handle; it opens the file.
|LPCTSTR lpFileName,||// address of name of the file|
|GENERIC_WRITE,||// access (read-write) mode // changing dates is considered writing.|
|FILE_SHARE_READ|FILE_SHARE_WRITE,||// share mode|
|NULL,||// address of security descriptor|
|OPEN_EXISTING,||// how to create|
|0,||// file attributes|
|NULL||// handle of file with attributes to copy|
The SetFileTime function sets the date and time that a file was created, last accessed, or last modified. Java timestamps use 64-bit milliseconds since 1970 GMT (Greenwich Mean Time). Windows timestamps use 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. Microsoft uses the Gregorian calendar ignoring the missing 12 days between 1752 Sep 2 Wednesday and by 1752 Sep 14 Thursday.
|HANDLE hFile,||// identifies the file|
|CONST FILETIME * lpftCreation,||// time the file was created. little endian.|
// NULL to leave as is.
|CONST FILETIME * lpftLastAccess,||// time the file was last accessed.|
// NULL to leave as is.
|CONST FILETIME * lpftLastWrite||// time the file was last written.|
As you might guess from my detailed instructions, I have written an untouch utility already. Mine uses pure java and supports several command line switches:
This page is posted
Optional Replicator mirror
Your face IP:[188.8.131.52]
You are visitor number|