package jetbrains.mps.smodel.resources; /*Generated by MPS */ import jetbrains.mps.make.resources.IPropertiesIO; import jetbrains.mps.vfs.IFile; import java.util.Map; import java.io.IOException; import jetbrains.mps.baseLanguage.closures.runtime.Wrappers; import java.util.Properties; import jetbrains.mps.smodel.ModelAccess; import java.io.InputStream; import java.util.HashMap; public class FlatFilePropertiesIO implements IPropertiesIO { private IFile descFile; public FlatFilePropertiesIO(IFile descFile) { this.descFile = descFile; } @Override public void writeProperties(Map<String, String> store) throws IOException { throw new UnsupportedOperationException(); } @Override public Map<String, String> readProperties() throws IOException { if (descFile == null) { return null; } IFile dir = descFile.getParent(); final IFile pf = dir.getDescendant("make.properties"); if (!(pf.exists())) { return null; } final Wrappers._T<Properties> props = new Wrappers._T<Properties>(null); ModelAccess.instance().runReadAction(new Runnable() { public void run() { InputStream is = null; try { is = pf.openInputStream(); props.value = new Properties(); props.value.load(is); } catch (IOException e) { } finally { try { if (is != null) { is.close(); } } catch (IOException ignore) { } } } }); return (Map<String, String>) ((props.value != null ? new HashMap(props.value) : null)); } @Override public Object getKey() { return (descFile != null ? descFile.getPath() : null); } }