--- /dev/null
+#ifndef VIRTUALFILESYSTEM_H_
+#define VIRTUALFILESYSTEM_H_
+
+#include <list>
+#include <map>
+#include <msp/fs/path.h>
+
+class Builder;
+class FileTarget;
+
+class VirtualFileSystem
+{
+public:
+ typedef std::list<std::string> SearchPath;
+
+private:
+ typedef std::map<std::string, FileTarget *> TargetMap;
+
+ Builder &builder;
+ TargetMap targets;
+ TargetMap include_cache;
+ TargetMap library_cache;
+
+public:
+ VirtualFileSystem(Builder &);
+
+ FileTarget *get_target(const Msp::FS::Path &) const;
+
+ void register_path(const Msp::FS::Path &, FileTarget *);
+
+ /** Tries to locate a header based on location of including file and include
+ path. Considers known targets as well as existing files. If a matching
+ target is not found but a file exists, a new SystemHeader target will be
+ created and returned. */
+ FileTarget *find_header(const std::string &, const Msp::FS::Path &, const SearchPath &);
+
+ /** Tries to locate a library in a library path. The library name should be
+ the same as would be given to the linker with -l, i.e. without the "lib"
+ prefix or extension. Considers known targets as well as existing files. If
+ a matching target is not found but a file exists, a new SystemLibrary target
+ will be created and returned. */
+ FileTarget *find_library(const std::string &, const SearchPath &, LibMode);
+
+private:
+ /**
+ Check if a header exists, either as a target or a file. Returns an existing
+ target of one was found, or a new SystemHeader target if there was no known
+ target but the file exists.
+ */
+ FileTarget *get_header(const Msp::FS::Path &);
+
+ FileTarget *get_library(const std::string &, const Msp::FS::Path &, LibMode);
+};
+
+#endif