<<config_reshare,*reshare*>> option.
-
=== File storage backend
-URL format: `+file:DIRECTORY+` or `+file://DIRECTORY+`
+URL format: `+file:DIRECTORY+` or `+file://[HOST]DIRECTORY+`
This backend stores data as separate files in a directory structure below
-*DIRECTORY* (an absolute path), similar (but not identical) to the primary cache
-storage. A typical use case for this backend would be sharing a cache on an NFS
-directory.
+*DIRECTORY*, similar (but not identical) to the primary cache storage. A typical
+use case for this backend would be sharing a cache on an NFS directory.
+*DIRECTORY* must start with a slash. *HOST* can be the empty string or
+localhost. On Windows, *HOST* can also be the name of a server hosting a shared
+folder.
IMPORTANT: ccache will not perform any cleanup of the storage -- that has to be
done by other means, for instance by running `ccache --trim-dir` periodically.
* `+file:/shared/nfs/directory+`
* `+file:///shared/nfs/directory|umask=002|update-mtime=true+`
+* `+file://example.com/shared/folder+`
Optional attributes:
private:
enum class Layout { flat, subdirs };
- const std::string m_dir;
+ std::string m_dir;
std::optional<mode_t> m_umask;
bool m_update_mtime = false;
Layout m_layout = Layout::subdirs;
};
FileStorageBackend::FileStorageBackend(const Params& params)
- : m_dir(params.url.path())
{
ASSERT(params.url.scheme() == "file");
- if (!params.url.host().empty()) {
- throw core::Fatal(FMT(
- "invalid file path \"{}\": specifying a host (\"{}\") is not supported",
- params.url.str(),
- params.url.host()));
+
+ const auto& host = params.url.host();
+#ifdef _WIN32
+ m_dir = util::replace_all(params.url.path(), "/", "\\");
+ if (!host.empty()) {
+ m_dir = FMT("\\\\{}\\{}", host, m_dir);
+ }
+#else
+ if (!host.empty() && host != "localhost") {
+ throw core::Fatal(
+ FMT("invalid file URL \"{}\": specifying a host other than localhost is"
+ " not supported",
+ params.url.str()));
}
+ m_dir = params.url.path();
+#endif
for (const auto& attr : params.attributes) {
if (attr.key == "layout") {