Skip to content

Commit f7285f3

Browse files
committed
Merge branch 'release/2.5.0'
Release v2.5.0 Fixes #37 Fixes #39 Fixes #41 Fixes #42
2 parents 5bbe240 + e820787 commit f7285f3

6 files changed

Lines changed: 301 additions & 50 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ All notable changes to this project are documented in this file.
66

77
This change log begins with the first public release version of _CompFileDate_. Releases are listed in reverse version number order.
88

9+
## Release v2.5.0 of 11 February
10+
11+
* Added support for comparing last access dates of the files being compared [[issue #37](https://github.com/ddabapps/compfiledate/issues/37)].
12+
* Added support to the Linux build for comparing last status change events of file instead of creation dates, which Linux doesn't support. This option is not supported on Windows. Passing the `c`, `created` or `creation` values to the `-d` / `--datetype` command on Linux results in a warning being issued and the last status change date being used instead [[issue #39](https://github.com/ddabapps/compfiledate/issues/39) & [issue #41](https://github.com/ddabapps/compfiledate/issues/41)].
13+
* Added further aliases for the `-d` / `--datatype` command values [[issue #41](https://github.com/ddabapps/compfiledate/issues/41)]. New creation date aliases, beyond those noted above, are not supported on Linux.
14+
* Added further aliases for the `-c` / `--compare` command values including arithmetic comparision operator symbols [[issue #42](https://github.com/ddabapps/compfiledate/issues/42)].
15+
* Updated the help screen re the changes in this release. Note that the help screen now differs between Windows and Linux builds.
16+
* Refactored code that checks for parameter values.
17+
* Updated the `Docs/ReadMe.txt` usage section re the changes in this release.
18+
919
## Release v2.4.0 of 5 February 2026
1020

1121
* Added 64 bit Linux support [[issue #28](https://github.com/ddabapps/compfiledate/issues/28)]. The Linux version works identically to the Windows versions except that the `--followshortcuts` (`-s`) command is not supported.

Docs/ReadMe.txt

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,56 +91,110 @@ where
9191
options are:
9292

9393
-c <op> or --compare=<op>
94+
9495
Defines the compare operation to use. <op> must be one of the following:
95-
eq, equal, same:
96+
97+
=, ==, eq, eql, equal, same
98+
9699
Checks if the dates of the files are equal.
97-
gt, newer, later:
100+
101+
>, gt, newer, later, after
102+
98103
Checks if the 1st file date is greater than (i.e. later than) the 2nd
99104
file date.
100-
gte, not-older, not-earlier
105+
106+
>=, gte, ge, goe, no-older, not-older, no-earlier, not-earlier,
107+
not-before
108+
101109
Checks if the 1st file date is greater than or equal to (i.e. no older
102110
than) the 2nd file date.
103-
lt, older, earlier
111+
112+
<, lt, older, earlier, before
113+
104114
Checks if the 1st file date is less than (i.e. earlier than) the 2nd
105115
file date. This is the default used if this option is not provided.
106-
lte, not-newer, not-later
116+
117+
<=, lte, le, loe, no-newer, not-newer, no-later, not-later, not-after
118+
107119
Checks if the 1st file date is less than or equal to (i.e. no newer
108120
than) the 2nd file date.
109-
neq, not-equal, not-same, different
121+
122+
<>, !=, ~=, neq, ne, not-equal, not-same, different
123+
110124
Checks if the dates of the files are not equal.
111125

126+
If <op> contains either a '<' or '>' character then the value must be
127+
enclosed in double quotes. On Linux single quotes may also be used. For
128+
example --convert="<=" and -c "<>"
129+
130+
112131
-d <type> or --datetype=<type>
113-
Determines whether the last modification or creation dates of the files are
114-
compared. <type> must be one of the following:
115-
m, modified, last-modified, modification:
132+
133+
Determines which date property of the files is used in the comparison.
134+
<type> must be one of the following:
135+
136+
m, modify, modified, last-modified, modification, update, updated,
137+
last-updated, write, written, last-written
138+
116139
Use the date the files were last modified. This is the default used if
117140
this option is not provided.
118-
c, created, creation:
119-
Use the date the files were created.
141+
142+
a, accessed, last-accessed, access, read, last-read
143+
144+
Use the date the files were last accessed.
145+
146+
c, create, created, creation
147+
148+
Windows:
149+
Use the date the files were created.
150+
151+
Linux:
152+
Linux does not support file creation dates.
153+
Parameters that were present in v2.4.0 (i.e. c, created and creation)
154+
are DEPRECATED. The date the status of the files was last changed is
155+
used instead, as if <type> had been "status-changed".
156+
Parameters introduced after v2.4.0 are not supported and cause the
157+
program to fail with exit code 108.
158+
159+
s, status, status-change, last-status-change, status-changed, metadata,
160+
metadata-change, last-metadata-change, metadata-changed
161+
162+
Linux:
163+
Use the date that the status (metadata) of the files was last updated.
164+
165+
Windows:
166+
Not supported because Windows files do not support status update
167+
dates. The program fails with exit code 108 if any of these date types
168+
is specified.
120169

121170
-s or --followshortcuts
171+
122172
Windows:
123173
Indicates that if either filename1 or filename2 is a shortcut (.lnk)
124174
file then the date of the shortcut's target file will be used in
125175
comparisons. If neither option is specified then shortcuts are not
126176
followed and the date of the shortcut file itself is used in the
127177
comparison.
178+
128179
Linux:
129180
Not supported because Linux does not support the Windows .lnk shortcut
130181
file format. The program fails with exit code 101 if either of the options
131182
is specified.
132183

133184
-v or --verbose
134-
Verbose: writes output to standard output. No output is written if the
185+
186+
Verbose. Writes output to standard output. No output is written if the
135187
option is not provided. Output is always written to standard error when an
136188
error occurs or to standard output when help or the program's version number
137189
are requested.
138190

139191
-h or -? or --help
192+
140193
Displays a help screen on standard output and halts. Any file names and
141194
other options are ignored.
142195

143196
-V or --version.
197+
144198
Displays the program's version number and platform on standard output and
145199
halts. Any file names and other options are ignored.
146200

Src/UDateExtractor.pas

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,35 @@ interface
1818
type
1919

2020
/// <summary>Method only record that exposes a method that gets either the
21-
/// creation or last-modified date from a file.</summary>
21+
/// creation, last-accessed or last-modified date from a file.</summary>
2222
TDateExtractor = record
2323
public
2424
type
2525
{$SCOPEDENUMS ON}
2626
/// <summary>Type of date to be extracted from a file.</summary>
2727
/// <remarks>
2828
/// <para>- LastModified - get date file was last modified.</para>
29-
/// <para>- Created - get date file was created.</para>
29+
/// <para>- Created - get date file was created (Windows only).</para>
30+
/// <para>- StatusChanged - get date when the file's status was was
31+
/// changed (Linux only).</para>
32+
/// <para>- LastAccessed - get date file was last accessed.</para>
3033
/// </remarks>
31-
TDateType = (LastModified, Created);
34+
TDateType = (
35+
LastModified,
36+
{$IF Defined(MSWINDOWS)}
37+
Created,
38+
{$ELSEIF Defined(LINUX)}
39+
StatusChanged,
40+
{$ENDIF}
41+
LastAccessed
42+
);
3243
{$SCOPEDENUMS OFF}
3344
public
34-
/// <summary>Gets either the creation or last-modified date from a file.
35-
/// </summary>
45+
/// <summary>Gets either creation, last-modified or last-accessed date from
46+
/// a file.</summary>
3647
/// <param name="FileName">[in] Name of the file to be examined.</param>
37-
/// <param name="DateType">[in] Specifies whether the last-modified or
38-
/// creation date is to be returned.</param>
48+
/// <param name="DateType">[in] Specifies whether the last-modified,
49+
/// last-accessed or creation date is to be returned.</param>
3950
/// <returns><c>TDateTime</c>. The required file date.</returns>
4051
class function GetDate(const FileName: string; const DateType: TDateType):
4152
TDateTime; static;
@@ -71,8 +82,17 @@ class function TDateExtractor.GetDate(const FileName: string;
7182
case DateType of
7283
TDateType.LastModified:
7384
Result := TFile.GetLastWriteTime(FileName);
85+
{$IF Defined(MSWINDOWS)}
7486
TDateType.Created:
7587
Result := TFile.GetCreationTime(FileName);
88+
{$ELSEIF Defined(LINUX)}
89+
TDateType.StatusChanged:
90+
// On Linux, TFile.GetCreationTime ultimately returns the _status.st_ctime
91+
// value, which is the status change date. Confusing!
92+
Result := TFile.GetCreationTime(FileName);
93+
{$ENDIF}
94+
TDateType.LastAccessed:
95+
Result := TFile.GetLastAccessTime(FileName);
7696
else
7797
raise Exception.Create('Invalid TDateExtractor.TDateType value');
7898
end;

Src/UMain.pas

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ TMain = class(TObject)
5656
/// </remarks>
5757
function AdjustFileName(const AFileName: string): string;
5858
{$IF not Defined(MSWINDOWS)}inline;{$ENDIF}
59-
/// <summary>Compares modification dates of the two files passed on the
60-
/// command line using the user's chosen comparison operation and returns
61-
/// True if the comparison succeeds or False if not.</summary>
59+
/// <summary>Compares dates of the two files passed on the command line
60+
/// using the user's chosen comparison operation and returns True if the
61+
/// comparison succeeds or False if not.</summary>
6262
/// <param name="File1">[in] Information about the file that is the left
6363
/// hand operand of the comparison.</param>
6464
/// <param name="File2">[in] Information about the file that is the right
@@ -113,73 +113,128 @@ implementation
113113
Name of second file to be compared.
114114
115115
Options are:
116+
116117
''';
117118

118119
sHelpCompareCmd = '''
119-
-c <op> or --compare=<op>'
120+
-c <op> or --compare=<op>
121+
120122
Defines the compare operation to use. <op> must be one of the
121123
following:
122-
eq, equal, same:
124+
=, ==, eq, eql, equal, same:
123125
Check if file dates are the same.
124-
gt, newer, later:
126+
>, gt, newer, later, after:
125127
Check if 1st file date is later than 2nd file date.
126-
gte, not-older, not-earlier:
128+
>=, gte, ge, goe, no-older, not-older, no-earlier, not-earlier,
129+
not-before:
127130
Check if 1st file date is no earlier than 2nd file date.
128-
lt, older, earlier:
131+
<, lt, older, earlier, before:
129132
Check if 1st file date is earlier than 2nd file date (default if
130133
option is not provided).
131-
lte, not-newer, not-later:
134+
<=, lte, le, loe, no-newer, not-newer, no-later, not-later, not-after:
132135
Check if 1st file date is no later than 2nd file date.
133-
neq, not-equal, not-same, different:
136+
<>, !=, ~=, neq, ne, not-equal, not-same, different:
134137
Check if file dates are different.
138+
139+
'''
140+
{$IF Defined(MSWINDOWS)}
141+
+ '''
142+
If <op> contains either a '<' or '>' character then the value must be
143+
enclosed in double quotes.
144+
135145
''';
146+
{$ELSEIF Defined(LINUX)}
147+
+ '''
148+
If <op> contains either a '<' or '>' character then the value must be
149+
enclosed in single or double quotes.
136150
151+
''';
152+
{$ENDIF}
153+
154+
155+
{$IF Defined(MSWINDOWS)}
137156
sHelpDateTypeCmd = '''
138157
-d <type> or --datetype=<type>
139-
Determines whether last modification or creation dates are compared.
158+
159+
Determines whether last modification, last accessed or creation dates are
160+
compared.
140161
<type> must be one of the following:
141-
m, modified, last-modified, modification:
162+
m, modify, modified, last-modified, modification, update, updated,
163+
last-updated, write, written, last-written:
142164
Use date files were last modified (default if option is not provided).
143-
c, created, creation:
165+
a, accessed, last-accessed, access, read, last-read:
166+
Use date files were last accessed.
167+
c, create, created, creation:
144168
Use date files were created.
169+
145170
''';
171+
{$ELSEIF Defined(LINUX)}
172+
sHelpDateTypeCmd = '''
173+
-d <type> or --datetype=<type>
174+
175+
Determines whether last modification, last accessed or last status update
176+
dates are compared.
177+
<type> must be one of the following:
178+
m, modify, modified, last-modified, modification, update, updated,
179+
last-updated, write, written, last-written:
180+
Use date files were last modified (default if option is not provided).
181+
a, accessed, last-accessed, access, read, last-read:
182+
Use date files were last accessed.
183+
s, status, status-change, last-status-change, status-changed,
184+
metadata, metadata-change, last-metadata-change, metadata-changed:
185+
Use date files last had status updates.
186+
c, created, creation:
187+
DEPRECATED: use status-changed instead.
188+
These values are treated as aliases for status-changed and a warning
189+
is displayed.
190+
191+
''';
192+
{$ENDIF}
146193

147194
{$IF Defined(MSWINDOWS)}
148195
sHelpFollowShortcutsCmd = '''
149196
-s or --followshortcuts
197+
150198
Indicates that if either filename1 or filename2 is a shortcut file then
151199
the date of the target file will be used in comparisons. If neither option
152200
is specified then shortcuts are not followed and the date of the shortcut
153201
file itself is used.
202+
154203
''';
155204
{$ELSEIF Defined(LINUX)}
156205
sHelpFollowShortcutsCmd = '''
157206
-s or --followshortcuts
158207
<<Not supported on Linux>>. Reports an error if used.
208+
159209
''';
160210
{$ENDIF}
161211

162212
sHelpVerboseCmd = '''
163213
-v or --verbose
164-
Verbose: writes output to standard output. No output is written if the
214+
215+
Verbose. Writes output to standard output. No output is written if the
165216
option is not provided. Output is always written to standard error when an
166217
error occurs or to standard output when help or the program's version
167218
number are requested.
219+
168220
''';
169221
170222
sHelpHelpCmd = '''
171223
-h or -? or --help
224+
172225
Displays help screen. Rest of command line ignored.
226+
173227
''';
174228
175229
sHelpVersionCmd = '''
176230
-V or --version
231+
177232
Displays program version number and platform. Rest of command line
178233
ignored.
234+
179235
''';
180236
181237
sHelpOutro = '''
182-
183238
The program's exit code is 1 if the comparison is true and 0 if it is false.
184239
185240
If an error occurs then an error code >= 100 is returned and an error message
@@ -199,7 +254,14 @@ implementation
199254
sFailureReport = 'Comparison using %s is false';
200255

201256
sDateTypeModified = 'last modification dates';
257+
{$IF Defined(MSWINDOWS)}
202258
sDateTypeCreated = 'creation dates';
259+
{$ELSEIF Defined(LINUX)}
260+
sDateTypeStatusChanged = 'status change dates';
261+
{$ENDIF}
262+
sDateTypeAccessed = 'last access dates';
263+
264+
sWarning = 'WARNING: %s';
203265

204266
const
205267
TrueResponses: array[TDateComparer.TOp] of string = (
@@ -209,7 +271,13 @@ implementation
209271
sNEQ, sGTE, sLTE, sGT, sLT, SEQ
210272
);
211273
DateTypeResponses: array[TDateExtractor.TDateType] of string = (
212-
sDateTypeModified, sDateTypeCreated
274+
sDateTypeModified,
275+
{$IF Defined(MSWINDOWS)}
276+
sDateTypeCreated,
277+
{$ELSEIF Defined(LINUX)}
278+
sDateTypeStatusChanged,
279+
{$ENDIF}
280+
sDateTypeAccessed
213281
);
214282

215283

@@ -381,6 +449,11 @@ procedure TMain.SignOn;
381449
);
382450
// Record that we've signed on
383451
fSignedOn := True;
452+
// Report any warnings
453+
for var Warning in fParams.Warnings do
454+
fConsole.WriteLn(
455+
TConsole.TChannel.StdErr, string.Format(sWarning, [Warning])
456+
);
384457
end;
385458

386459
end.

0 commit comments

Comments
 (0)