Class FileVersion
Class FileVersion
Object
|
+----FileVersion
- public class FileVersion
- extends Object
This tool has a very specific intended purpose though it might
end up with greater applicability: when connected to the right-mouse's
"Send To" menu on Windows 95 or on Windows NT, it will let you make a
"ShapShot" of the selected file by managing what I call a VersionSET -
a group of files that "share the same name" in the sense described below.
For example:
D:\kevin\JavaApps\FileVersion\MySrcFile.java
D:\kevin\JavaApps\FileVersion\MySrcFile-01.java
...
D:\kevin\JavaApps\FileVersion\MySrcFile-12.java
shows such a set. The "name" of the file is MySrcFile and
it's a "Java" source file; that's the model that the tool is intended
to support. The VersionIDs let you keep a sequence of these files so
that you can go back and revisit the edit history, make backup copies,
and etc. In short, this is a very poor man's source code control
done on top of an ordinary file system. In the above, the VersionIDs
"-01" .. "-12" show the history while the first file distinguishes
itself as the primary one by having an empty VersionID. Normally, this
'root' element is the one that you point to when you invoke this tool
but, in fact, you could point to any element of the VersionSET and
you get exactly the same semantics - described further below.
Usage: FileVersion [-v | -f] file_name[-NN].ext
Make a snap shot of the indicated file in the current directory.
This SnapShot file, intended for archival purposes, is actually
produced by renaming the indicated file using an NN that is one
higher than the highest one in the containing directory. An exact
copy of this file (with the current date and time) is created using
the name given since the paradigm is that you are about to make
changes to it.
Options
-v (for 'verbose') => extra messages; See: doVerbose
-d (for 'dump') => verify VersionSET; See: doFileList
If you invoke this command with no arguments a brief "Usage Summary" is
written to standard output; otherwise a real "success" message is produced.
But in either case remember that if you are using this tool via your right-mouse
"SendTo" menu, the "results" of the command are expected to appear in your
Explorer window; you might not see any messages that are produced by the
tool itself since it executes in a "DOS window" (or something like that) so
you have to watch closely to even see the window "flash" by. When I really
want to see messages produced by the tool I run it from a .bat file from
right-mouse OR I invoked it directly from a DOS window "by hand".
- Version:
- "initial release" : September 2, 1998
- Author:
- Kevin G. Pammett, created August 30, 1998
Copyright (c) Pammett Family Enterprises, all rights reserved.
- See Also:
- versionID, FVnameFilter
-
FileVersion()
-
-
cpyFile(String, String)
- Make the copy of the "input" file so that the "toFile" File
ends up with the same contents (although not the same date
and time, etc.)
-
extractVersion(String)
- Decide which part (substring) within a file name gets counted as
the "version ID" (the -NNN) part.
-
main(String[])
- Command-line interpreter for this application.
-
maximizeVersionID()
- Figure out what is the "highest" VersionID associated with the
entire set of files that belong to the current VersionSET.
-
parseBase(String)
- Tear apart the FULL file name into its constituent parts,
at least insofar as this tool is concerned.
-
realName(File)
- This method is called when we "know" that the input file name
is one of those bogus MS-DOS names and it scans the containing
directory to "sniff out" which file it really is.
FileVersion
public FileVersion()
cpyFile
public static void cpyFile(String fromFile,
String toFile) throws IOException
- Make the copy of the "input" file so that the "toFile" File
ends up with the same contents (although not the same date
and time, etc.)
- Parameters:
- fromFile - The full pathname for the file we're manipulating.
- toFile - TBD The full pathname for the file we're manipulating.
extractVersion
public static java.lang.String extractVersion(String fileLeafName)
- Decide which part (substring) within a file name gets counted as
the "version ID" (the -NNN) part. This mechanism is (currently) only
used while we are going thru all files in the current directory,
so it is not expecting a full pathname - with directory part - but
rather just the 'leaf' name.
the "version ID" (the -NNN) part. This mechanism is like
is used whhile we are parsing the name into parts: xyz-nnn.xtn
- Parameters:
- fileLeafName - The leaf part of a file pathname, known to be in
the same directory as the primary file we are manipulating.
- See Also:
- baseName, maximizeVersionID()
main
public static void main(String[] args)
- Command-line interpreter for this application.
//// //// ////
//// //// //// Tool entry point and command-line interpretation
//// //// ////
For details on how to invoke the "File Version SnapShot" tool please
see the Usage Instructions that appear
at the top of this "package".
- Parameters:
- args - Array of parameters passed to the application
via the command line.
- See Also:
- IncrementVersion()
maximizeVersionID
public static void maximizeVersionID()
- Figure out what is the "highest" VersionID associated with the
entire set of files that belong to the current VersionSET.
This is "step 2" of the
overall algorithmic description
for this tool, the one which decides how "increment" will work.
The "pure Java" solution is to use the File and FileFilter
objects to sort out the candidates for this VersionSET.
- See Also:
- parseBase(java.lang.String), extractVersion(java.lang.String), IncrementVersion()
parseBase
public static void parseBase(String fullName)
- Tear apart the FULL file name into its constituent parts,
at least insofar as this tool is concerned.
The algorithm used by this tool is based on seeing a full file
pathname as being made up of N distinct parts: (a) device and
directory, (b) base name, (c) versionID, and (d) extension; this
routine is primarily responsible for determining exactly how
a given fullName gets broken down into these parts.
- Parameters:
- fullName - The full pathname for the file we're manipulating.
- See Also:
- maximizeVersionID(), IncrementVersion(), IsOkVersionID(char)
realName
public static java.lang.String realName(File wrtFile)
- This method is called when we "know" that the input file name
is one of those bogus MS-DOS names and it scans the containing
directory to "sniff out" which file it really is.
Since we cannot rely on file pathnames or any of the functions
that are a function of those names, there's not much we can do
except to apply a heuristic that usually works. In this case
we pick up the Size and Last-Modified times of the "source"
file, and match that to any file we find in the same directory
that has a matching Size and Last-Modified time.
- Parameters:
- wrtFile - The full pathname for the file we're manipulating.