Why are some System.IOUtils.Tfile procedures selective?

I use Beyond Compare to keep some files aligned in a couple places. The problem I had is once I updated changes and saved the modified file copies the file dates are different and when Beyond Compare is next opened I had to manually cycle through the files to make sure they were still aligned. Simple to fix in Delphi – compare the file contents and if they are the same align the file “Last Write” dates.

Some of my file directories are however on mapped drives on the VMWare Linux host

(Eg Z:\UnixData.Test.MyFile.Txt)

And while

TFile.GetLastWriteTime(‘ Z:\UnixData.Test.MyFile.Txt’);

returns the correct time.

SetLastWriteTime(‘Z:\UnixData.Test.MyFile.Txt’, NewTime); 

has no effect.

Similarly Tfile.Copy with overwrite set to true will not work but if any existing file is deleted first the copy does proceed but the file dates are not copied.

I do have a solution. If I use the Samba access to the host files

SetLastWriteTime(‘\\HostName\Share\Directory\Tree\FileName.txt', NewTime);

all TFile functions work as as expected.

Why would VMWare Mapped Drives act this way?
I note that if I run my program as administrator the mapped drives do not appear.

Hey Roger, what about a different solution: use file contents comparison in Beyond Compare instead of timestamp.Disable “compare timestamps” and enable “compare contents” and “skip if quick tests indicate files are the same”. It will be slower if the timestamps differ but will ignore files that have no content changes. See: Folder Compare Comparison Settings

Thanks Jarrod

I did think there may be a solution in BC. Through the process and your post I have also learned a lot more about BCs capabilities,

The Delphi Solution was trivial (until I hit the VM Mapped drive issue) and opens up the potential for more customized functionality.

1 Like