ID:2857912
 
Resolved
fexists() can now be used inside of an #if preprocessor conditional expression.
Applies to:DM Language
Status: Resolved (515.1602)

This issue has been resolved.
Currently, there is no way to check if a file exists, and include it if so.

I propose a compiler directive / if-else that allows it:

#ifexists "config.dm"
  #define CUSTOM_CONFIG 1
  #include "config.dm"
#else
  #define CUSTOM_CONFIG 0
  #warn Using default configuration.
  #include "default_config.dm"
#endif


This could be used to bundle a default configuration in a project's repository, without requiring that the end-user gitignore or otherwise tamper with the included one.

It can also be used for cases where a library may or may not be present; for example, Goonstation's current code requires that the user create an empty directory and file because there is no programmatic way to detect the presence of the files or not.


Lummox JR resolved issue with message:
fexists() can now be used inside of an #if preprocessor conditional expression.