Re: file_exists and file name in quotes

new topic     » goto parent     » topic index » view thread      » older message » newer message
clk824 said...

I have file name with spaces inside and it is enclosed in quotes. This is standard rule. file_exists return false with this quotes, but without quotes system_exec not work. Seems to be bug in file_exists?

eu4, windows

Are you saying you are trying something like this ...

sequence filename 
 
filename = "\"My File With Spaces.txt\"" 
 
if file_exists(filename) then 
    system_exec("somecmd " & filename) 


And file_exists() always reports the file as missing?

If so, I think that this is not a bug. There are many library routines that take a file name as a parameter, and none of them (as far as I can remember) strip off enclosing quotes.

Note that the system_exec() routine does not take a file name as a parameter, instead it takes a command line as a parameter and it is the command line that needs quoted files.

May I suggest that you code more like this instead ...

sequence filename 
 
filename = "My File With Spaces.txt" 
 
if file_exists(filename) then 
    system_exec(sprintf(`somecmd "%s"`, {filename})) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu