Jump to content
SteCam

How to exclude backup files with tilde character at end of file extension

Recommended Posts

Posted (edited)

I have a Delphi XE app that targets files with the '.yml' extension in a user-selected folder. A user reported that the app was giving duplicate results. It turns out that the user is running the app on Linux with Wine and uses an editor that creates backup files with the '.yml~' extension (per Linux convention) in the same folder. To my surprise I find that such files are not excluded by a line in my code such as 

i := FindFirst(strPath + '*.yml', faAnyFile, SearchRec);

That is, the file mask '* .yml' also picks up '*.yml~'. Is there a way of specifying the file mask so that this does not occur?

 

Edited by SteCam

Share this post


Link to post
2 hours ago, SteCam said:

That is, the file mask '* .yml' also picks up '*.yml~'. Is there a way of specifying the file mask so that this does not occur?

Unfortunately no, there is not. You will have to look at the actual extension in SearchRec.Name and ignore any files that are not exactly '.yml'.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×