RobinAtTech
RobinAtTech

Reputation: 1329

Inno Setup Avoiding exceptions in ExtractTemporaryFiles when no matching files are found

I have an issue with ExtractTemporaryFiles while extracting *.sql files

I don't always have SQL scripts inside [Files] section to extract as mentioned below. My problem is ExtractTemporaryFiles('*.sql') raises an exception if no sql files are included with the installation.

Internal error: ExtractTemporaryFiles: No files matching "*.sql" found.

I can use try:except or another ugly way like, including a dummy.sql with the installation always. So I can make sure ExtractTemporaryFiles has a file to extract it always.

But I want to know What is the best way of avoiding exception in this case?

[Files]
Source: "Input\SQLSCRIPTS\*"; DestDir: "SQLSCRIPTS"; Flags: ignoreversion dontcopy skipifsourcedoesntexist

Upvotes: 2

Views: 1071

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202118

You can use a preprocessor to conditionally skip the ExtractTemporaryFiles call:

#if FindFirst("Input\SQLSCRIPTS\*.sql", 0)
  ExtractTemporaryFiles('*.sql');
#endif

Upvotes: 1

Related Questions