[feat] Implement a new compile switch for file search strategy
Hello! 🌍💻
I would like to propose an enhancement to the Cosmopolitan Libc library, which aims to make it more flexible and user-friendly. Currently, Cosmopolitan Libc uses PKZIP Executables as pretty good containers, and file IO operations are handled by replacing the original file system with a custom mechanism where files prefixed with '/zip/' are treated as assets within an executable file.
I would like to introduce a new compile switch: FILE_SEARCH_STRATEGY, which allows users to decide how Cosmopolitan Libc handles file operations. By adding this feature, developers will be able to add support for opening and executing asset files without needing to modify their project's source code.
The proposed FILE_SEARCH_STRATEGY compile switch would have the following behavior:
- 0 - File system priority: Cosmopolitan Libc would first look for a file in the file system, falling back to searching within the executable asset files if not found.
- 1 - Executable asset files priority: The library will prioritize searching for files within the executable asset files and fall back to looking in the file system if necessary.
If FILE_SEARCH_STRATEGY is not defined, it would be assumed that the feature is disabled, maintaining Cosmopolitan Libc's backward compatibility with existing projects.
This new functionality will give developers more control over how their applications interact with files and make it easier to work with executable asset files in a seamless manner. I believe this enhancement could benefit many users who are looking for ways to simplify the management of assets within their applications, making Cosmopolitan Libc even more powerful and versatile.
cosmocc --FILE_SEARCH_STRATEGY=0 -o hello hello.c