// XXX lock any loaded XML files while the project is modified, to prevent manual editing,
 // and reload any modified files if the project is unmodified
 private MakeProjectHelperImpl(
     FileObject dir, Document projectXml, ProjectState state, MakeProjectTypeImpl type) {
   this.dir = dir;
   try {
     this.fileSystem = dir.getFileSystem();
   } catch (FileStateInvalidException ex) {
     throw new IllegalStateException(ex);
   }
   this.state = state;
   assert state != null;
   this.type = type;
   assert type != null;
   this.projectXml = projectXml;
   projectXmlValid = true;
   assert projectXml != null;
   fileListener = new FileListener();
   FileObject resolveFileObject = resolveFileObject(PROJECT_XML_PATH);
   if (resolveFileObject != null) {
     resolveFileObject.addFileChangeListener(fileListener);
   } else {
     FileSystemProvider.addFileChangeListener(fileListener, fileSystem, PROJECT_XML_PATH);
   }
   resolveFileObject = resolveFileObject(PRIVATE_XML_PATH);
   if (resolveFileObject != null) {
     resolveFileObject.addFileChangeListener(fileListener);
   } else {
     FileSystemProvider.addFileChangeListener(fileListener, fileSystem, PRIVATE_XML_PATH);
   }
 }
 private String resolvePath(String filename) throws IllegalArgumentException {
   if (filename == null) {
     throw new NullPointerException("null filename passed to resolveFile"); // NOI18N
   }
   String result;
   if (RELATIVE_SLASH_SEPARATED_PATH.matcher(filename).matches()) {
     result = dir.getPath() + CndFileUtils.getFileSeparatorChar(fileSystem) + filename;
   } else {
     result = filename;
   }
   return FileSystemProvider.normalizeAbsolutePath(result, fileSystem);
 }
 private static FileObject substituteIfNeed(FileObject dir, Document projectXml) {
   if (!dir.getNameExt().endsWith("shadow")) { // NOI18N
     return null;
   }
   Element root = projectXml.getDocumentElement();
   if (root != null) {
     String mode = getNodeValue(root, MakeProject.REMOTE_MODE);
     if (RemoteProject.Mode.REMOTE_SOURCES.name().equals(mode)) {
       String hostUid = getNodeValue(root, MakeProject.REMOTE_FILESYSTEM_HOST);
       String remotebaseDir = getNodeValue(root, MakeProject.REMOTE_FILESYSTEM_BASE_DIR);
       if (hostUid != null && remotebaseDir != null) {
         ExecutionEnvironment env = ExecutionEnvironmentFactory.fromUniqueID(hostUid);
         FileObject fo = FileSystemProvider.getFileObject(env, remotebaseDir);
         return fo;
       }
     }
   }
   return null;
 }