1 #ifndef VIRTUALFILESYSTEM_H_
2 #define VIRTUALFILESYSTEM_H_
6 #include <msp/fs/path.h>
13 Provides access to the filesystem in a way that takes known targets into
14 account. Thus, targets may be returned for files that do not exist yet if it's
15 possible to build them.
17 class VirtualFileSystem
20 typedef std::list<Msp::FS::Path> SearchPath;
23 typedef std::map<Msp::FS::Path, FileTarget *> TargetMap;
27 std::set<Msp::FS::Path> nonexistent;
30 VirtualFileSystem(Builder &);
32 FileTarget *get_target(const Msp::FS::Path &) const;
34 /** Registers a target with the VFS. A target may be registered at multiple
35 paths if building it results in multiple files. */
36 void register_path(const Msp::FS::Path &, FileTarget *);
38 /** Locates a source file. If a file is found but no target is associated
39 with it, a new package-less target is created with the appropriate tool. */
40 FileTarget *find_header(const std::string &, const SearchPath &);
42 /** Locates a library. The library name should be the same as what would be
43 used in linking with the library. If a file is found but no target is
44 associated with it, a new package-less target of appropriate type is
46 FileTarget *find_library(const std::string &, const SearchPath &, LibMode);
49 bool file_exists(const Msp::FS::Path &);