File resourceFile = null; // should be non-null by the time we create the output stream.
if (getResourceType() != ModuleSourceDefinition.RESOURCE_TYPE) {
// A module store which is not a cal source store.
// Attempt to co-locate the module resources with the CAL source file.
FilePath resourceFilePath = getResourcePath(resourceName);
// (But don't change the location if the file already exists).
if (!getNullaryEnvironment().exists(resourceFilePath)) {
// Extract the module name (if any) from the resource name.
FeatureName featureName = resourceName.getFeatureName();
if (featureName instanceof CALFeatureName) {
CALFeatureName calFeatureName = (CALFeatureName)featureName;
if (calFeatureName.hasModuleName()) {
ModuleName moduleName = calFeatureName.toModuleName();
// Get the base file path from the path mapper and use this to get the file with the right base folder.
ResourceName moduleResourceName = new ResourceName(CALFeatureName.getModuleFeatureName(moduleName));
FilePath baseFilePath = CALSourcePathMapper.INSTANCE.getResourcePath(moduleResourceName);
resourceFile = getNullaryEnvironment().getFile(baseFilePath, resourceFilePath, true);
}
}
}
}