FileTimes 2.0 build: 9639 released: 2012-12-11 compiled with: Java 1.8.0_131 Jet jet12.0-pro-x86/1.8.0_131

Get/Set Windows File Times Create/Modified/Accessed JNI class..

Copyright: (c) 1997-2017 Canadian Mind Products.

Java application.
Download from: http://mindprod.com/products1.html#FILETIMES

----

Notes:

You must install the Java JRE to use this program.
See http://mindprod.com/jgloss/jgloss/jre.html

This program can only be used from the command prompt, (or via an command
line style icon shortcut) e.g. under Windows command.exe or JPSoft
tcmd.exe, formerly called the DOS box. Just clicking the programs in a
directory listing will not do anything useful. Just typing the program
names at the command prompt will not either.

This program requires a manual install! See below.

This program works with vanilla text files, (e.g. ASCII files or UTF-8
Unicode files). You will need a text editor to create and view them, not a word
processor. e.g. notepad, Visual Slick Edit or other suitable text editor
http://mindprod.com/jgloss/editor.html. You must use a monospaced font
http://mindprod.com/jgloss/monospacedfonts.html (aka fixed pitch, aka
programmer font) to view your files, or they won't look properly aligned.

I put out an avalanche of free software into the world, and submit PAD
files to hundreds of distribution sites, but I rarely hear back from
anyone.  What's happening?  Does it all just work fine?  It is so
complicated nobody can figure out how to use it and they give up on it?
It is it useful?  Since everyone has the source, do people just fix the
programs to their liking themselves?  Did you have trouble installing?  Do
I presume you know too much?  I would be happy to hear from you about your
experiences, positive or negative and your requests for improvements.  A
one-line email to roedy@mindprod.com would be great.

===> Free <===
Full source included.
You may even include the source code, modified or unmodified
in free/commercial open source/proprietary programs that you write and distribute.
May be used freely for any purpose but military.
For more details on this restriction, see
http://mindprod.com/contact/nonmil.html
If you include any Canadian Mind Products code in your own applications,
your app too must be labelled non-military use only.
http://mindprod.com/contact/nonmil.html
All Java jars and source code are included. If you need the class files or Javadoc, you will have to build them yourself. To streamline the zip downloads, class files and Javadoc have been removed.

----

Prerequisites:

This program runs under any OS that supports Java,
(e.g.W2K/XP/W2003/Vista/W2008/W7-32/W7-64/W8-32/W8-64/Linux/LinuxARM/LinuxX86
/LinuxX64/Ubuntu/Solaris/SolarisSPARC/SolarisSPARC64/SolarisX86/SolarisX64/OSX/AIX...)
so long as you have
<><> Java version 1.8 <><> or later installed (32-bit or 64-bit Java).
See http://mindprod.com/jgloss/installingjava.html for details.

----

Installing on a PC:

Download source and compiled jar files to run on your own machine as an application.
First install a recent Java JDK or JVM.
See http://mindprod.com/jgloss/installingjava.html.
To install, extract the zip download with WinZip
(or similar unzip utility) into any directory you please,
often J:\ --  ticking off the <span class="click">use folder names</span> option.

This program uses JNI which requires an awkward manual installation step.
Copy filetimes.32.dll and filetimes.64.dll to a directory on the path/library.path.
Type PATH at the command prompt to discover the path directories.

To run as an application, type:
java.exe %JAVA_OPTIONS -ea -jar J:\com\mindprod\filetimes\filetimes.jar {put any parms here}

adjusting as necessary to account for where the jar file is.

----

Installing on a MacIntosh:

Use Safari to download source and compiled jar files to run on your own machine as an application.
Safari will automatically unpack the zip into ~/Downloads (version 10.5)
[or on the Desktop (version 10.4 and earlier)].
First install a recent Java JDK or JVM.
See http://mindprod.com/jgloss/installingjava.html.
You may optionally move the download tree to a permanent home.
I don't have a MacIntosh, just a PC, so I can't test my Java programs for Mac compatibility.
In theory they should work without problems, but in practice that does not always happen.
If you have problems please, let me know, preferably with screenshots and complete verbatim error messages.

This program uses platform-specific JNI.
I do not yet have a Mac version of the C/C++ JNI code.
If you are technically savvy, you could create it yourself.

To run as an application, without parameters, just double click the jar file.

To run as an application with parameters, in bash shell type:
open Terminal.app
cd ~/Desktop
java.exe -ea -jar com/mindprod/filetimes/filetimes.jar {put any parms here}

adjusting as necessary to account for where the jar file is.

----

Rebuilding:

The zip already contains the necessary jar files, so unless you modify
the program, there is no need to recompile the source or rebuild the jar.
Configure.java basedir="E:/" in rebuild.xml to the drive where your files are.
Use ANT and rebuild.xml, not build.xml, to recompile and recreate the jar.

----

Use:

Gets and sets the various Windows file and directory times
from Java: create date, last access date and last modified
date. Uses JNI and C native code.
Create time is when the file was first written. Modified
time (sometimes called lastModified) is when the file was
last written. Accessed time is when the file was last read
or written. Checking its date, looking at its attributes or
checking to see if it exists does not count as reading it.
Get/Set Windows File Times Create/LastAccessed/LastModified
with a JNI native code class. It now also works an
directories.
Java and JNI you include in your own code.
You can test with
  C:
  CD \com.mindprod.filetimes
  java com.mindprod.filetimes.FileTimes
This does nothing useful, just exercises the filetimes class.
and ensuring nativefiletimes.dll is on the path, e.g. in the
current directory.  YOU MUST MANUALLY EXTRACT
NATIVEFILETIMES.DLL and put it on the path. See
http://mindprod.com/jgloss/path.html
The key to making FiletTimes work is putting the DLL somewhere on the path
or the java library path where Java.exe can find it.
See http://mindprod.com/applet/wassup.html if you don't know which
directories are suitable homes for the DLL.  Download and install wassup.  Run
it as an application, not an Applet.  Check "restricted", and look at the:
java.library.path =
E:\sys;.;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;F:\Program
Files (X86)\jet7.6-pro\bin;E:\Program
Files\Java\jdk1.7.0\bin;E:\env;E:\sys;F:\Program Files
(x86)\JPSoft\TCMD13;F:\Program Files\vslick\win;F:\Program Files
(x86)\apache-ant-1.8.2\bin;F:\Program
Files\PostgreSQL\9.0\bin;E:\com\mindprod\reorg;F:\Program
Files\TortoiseSVN\bin;F:\Program Files (x86)\asm;F:\Program Files
(x86)\Microsoft Visual Studio 10.0\Common7\IDE\;F:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\BIN;F:\Program Files (x86)\Microsoft
Visual Studio
10.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program
Files (x86)\Microsoft SDKs\Windows\v7.0A\bin;c:\Program Files
(x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL
Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\
These are places you could put the DLL. Your list will be different.
Failing that, try putting it on the path.
You can also use the ft utility get detailed date/time information about a
list of files, e.g.
  C:
  CD \com.mindprod.filetimes
  java com.mindprod.filetimes.FT  C:\temp\temp.txt  E:\env\bk.bat
See FileTimes.java for the API to use these methods in your
own programs. FileTimes does nothing by itself, other than a
debugging test harness to demonstrate the methods.
Windows keeps file timestamps accurate to 100 nanoseconds
with 10,000 times as much precision as Java's 1 ms.  This
means if you copy a file in Java, the new file will not
have the exact same timestamp as the old. This package
retrieves and sets timestamps accurate only to the
millisecond.
Beware, virus checker Windows 3000 File System Monitor AMON
of NOD32, will interfere with FileTimes and set the file
last-Access date to the current time any time you attempt to
set it to some value.  Other virus checkers might similarly
interfere.
Vista, by default, to improve performance, does not maintain
the last-access-dates of files. You can use the utility
fsutil to turn tracking back on. For details, see
http://mindprod.com/jgloss/fsutil.html
There is also included the TouchDirs utility.
You can run it like this
java.exe -jar touchdirs.jar  C: D:
which will modify the last access times of all the
directories to the current time. If you immediately
subsequently defrag with O&O Defrag with COMPLETE/Access
option, it will pull all the directories together, in natural
tree order for faster access.
TouchDirs cannot modify a read-only directory.  To condition your
disk for TouchDirs, use the TakeCommand command
attrib /D /A:+D /S -r-h *.*
to remove the read-only and hidden attributes from your directories.
There are also directories that Windows will not let you touch such as
X:\System Volume Information
C:\Windows\winsxs\*
  String test file = "C:/temp/somefile";
  FileTimes.setFileTimes( testFile,
    /* set created 2 days ago */
    System.currentTimeMillis()
    - 2 * 24 * 60 * 60 * 1000L,
    /* set accessed 2 hours ago */
    System.currentTimeMillis()
    - 2 * 60 * 60 * 1000L,
    /* updated 24 hours =  1 day ago */
    System.currentTimeMillis()
    - 24 * 60 * 60 * 1000L );
    long current = System.currentTimeMillis();
    // do last accessed First, in case others disturb it.
    long lastAccessed = FileTimes.getFileLastAccessed( testFile );
    long created = FileTimes.getFileCreated( testFile );
    long lastModified = FileTimes.getFileLastModified( testFile );
Why the three ball C M A icon?  It stands for the three
timestamps, create, modified and accessed.
This program requires modules from the Microsoft C++ Express
9 run time library. Normally they should be automatically
statically included. However, if someone recompiled the JNI
C++ code without the /MT option, this code will not work
unless the vcredist_x86.exe Microsoft C++ Express 11 run time
library is preinstalled. You can download it from Microsoft
or CMP.
see http://mindprod.com/jgloss/cpp.html for details.
The symptom of this problem is an UnsatisfiedLinkError or a
side-by-side configuration error.
Implementation Strategy
-----------------------
Before you launch off writing your own code, makes sure the ft and
filetimes utilities work.  This will ensure you have properly installed
the nativefiletimes DLL on the path.
Then start with either FT.java or FileTimes.java and gradually modify them
a step a time to do what you want in your utility.  After every small
change, retest them to make sure they work.  Don't change the package
names of the native code or the JNI code.
This JNI code is for 32-bit Javas only.  It will not work with 64-bit
Java.  If you have access to a 64-bit Windows C/C++ compiler to you could
modify the C code to produce a 64 bit version.  For other platforms, you
are on your own.  I was unable to figure out why the code does not compile
under 64 bit. If you have any ideas what is is upset about, please
let me know.  The filetimes.64.dll is not provided.


----

Version History:

 1.4 2007-04-26

 1.5 2007-05-11 tidy code, add PAD and logo

 1.6 2007-06-13 add support for directory times.

 1.7 2007-07-28 fix bug, handles not always closed.

 1.8 2007-08-30 add TouchDirs, add setFileCreated, setFileLastAccessed, setFileLastModified

 1.9 2008-09-23 fix problem with Microsoft C++ auxiliary runtime library.

 2.0 2012-12-11 add 64-bit support.

-30-