congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CndFileUtils.toFileObject
Code IndexAdd Tabnine to your IDE (free)

How to use
toFileObject
method
in
org.netbeans.modules.cnd.utils.cache.CndFileUtils

Best Java code snippets using org.netbeans.modules.cnd.utils.cache.CndFileUtils.toFileObject (Showing top 20 results out of 315)

origin: org.netbeans.modules/org-netbeans-modules-cnd-apt

public FileObject getFileObject() {
  // using fileSystem.findResource is not safe, see #196425 -  AssertionError: no FileObject 
  return CndFileUtils.toFileObject(fileSystem, path);
}

origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

@Override
public FileObject getFileObject() {
  return CndFileUtils.toFileObject(file); // XXX:FileObject conversion
}

origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
protected boolean mimeAccept(File f) {
  return mimeAccept(CndFileUtils.toFileObject(f));
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

public static DataObject getDataObject(File file) {
  CndUtils.assertNormalized(file);
  return getDataObject(CndFileUtils.toFileObject(file));
}

origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

@Override
public FileObject getFileObject() {
  FileObject result;
  synchronized(this) {
    result = fileObject.get();
    if (result == null) {
      result = CndFileUtils.toFileObject(fileSystem, absPath);
      if (result == null) {
        result = InvalidFileObjectSupport.getInvalidFileObject(fileSystem, absPath);
      }
      fileObject = new WeakReference<>(result);
    } else {
      if (!result.isValid()) {
        result = CndFileUtils.toFileObject(fileSystem, absPath);
        if (result == null) {
          result = InvalidFileObjectSupport.getInvalidFileObject(fileSystem, absPath);
        }
        fileObject = new WeakReference<>(result);
      }
    }
  }
  return result;
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

@Override
public FileObject getFileObject() {
  FileObject result = CndFileUtils.toFileObject(fileSystem, absPath);
  if (result == null) {
    CndUtils.assertTrueInConsole(false, "can not find file object for " + absPath); //NOI18N
    result = InvalidFileObjectSupport.getInvalidFileObject(fileSystem, absPath);
  }
  return result;
}

origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

private static FileObject findFileObject(String fileName, FileSystem fs) {
  CndUtils.assertAbsolutePathInConsole(fileName);
  String normPath = FileSystemProvider.normalizeAbsolutePath(fileName, fs);
  return CndFileUtils.toFileObject(fs, normPath);
}

origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

@Override
public FileObject getFileObject() {
  FileObject fo = CndFileUtils.toFileObject(project.getFileSystem(), normalizedAbsPath);
  if (fo == null) {
    fo = InvalidFileObjectSupport.getInvalidFileObject(project.getFileSystem(), normalizedAbsPath);
  }
  return fo;
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

private ProjectBase createProject() throws IOException {
  NativeProject np = null;
  if (files.size() == 1 && files.get(0).getName().equals("project.xml")) { // NOI18N
    try {
      FileObject projectDir = CndFileUtils.toFileObject(
          files.get(0).getParentFile().getParentFile());
      Project p = ProjectManager.getDefault().findProject(projectDir);
      np = p.getLookup().lookup(NativeProject.class);
    } catch (IOException ioe) {
      throw new IllegalArgumentException(ioe);
    }
  } else {
    String projectRoot = files.isEmpty() ? File.separator
        : files.get(0).getParentFile().getAbsolutePath();
    np = NativeProjectProvider.createProject(projectRoot, files,
        libProjectsPaths,
        getSystemIncludes(), quoteIncludePaths, currentIncludeFiles, getSysMacros(),
        macros, undefinedMacros, pathsRelCurFile);
  }
  ProjectBase out = model.addProject(np, np.getProjectDisplayName(), true);
  waitProjectParsed(out, false);
  return out;
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

private boolean isExecutable(File file) {
  FileObject fo = null;
  if (file.getName().endsWith(".exe")) { //NOI18N
    return true;
  }
  try {
    fo = CndFileUtils.toFileObject(file.getCanonicalFile());
  } catch (IOException e) {
    return false;
  }
  if (fo == null || !fo.isValid()) { // 149058
    return false;
  }
  DataObject dataObject = null;
  try {
    dataObject = DataObject.find(fo);
  } catch (DataObjectNotFoundException e) {
    return false;
  }
  final String mime = dataObject.getPrimaryFile().getMIMEType();
  return mime.equals(MIMENames.SHELL_MIME_TYPE) || 
      mime.equals(MIMENames.BAT_MIME_TYPE) || 
      mime.equals(MIMENames.ELF_SHOBJ_MIME_TYPE) || 
      MIMENames.isBinaryExecutable(mime);
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

/**
 * tries to detect mime type of file checking cnd known types first
 * @param file file to check
 * @return one of mime types or "content/unknown"
 */
public static String getSourceFileMIMEType(File file) {
  FileObject fo = CndFileUtils.toFileObject(CndFileUtils.normalizeFile(file));
  String mime;
  if (fo != null && fo.isValid()) {
    // try fast check
    mime = getSourceFileMIMEType(fo);
  } else {
    mime = getKnownSourceFileMIMETypeByExtension(file.getPath());
  }
  return mime != null ? mime : "content/unknown"; // NOI18N
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

/**
 * tries to detect mime type of file checking cnd known types first
 * @param file file to check
 * @return one of mime types or "content/unknown"
 */
public static String getBinaryFileMIMEType(File file) {
  FileObject fo = CndFileUtils.toFileObject(CndFileUtils.normalizeFile(file));
  String mime;
  if (fo != null && fo.isValid()) {
    // try fast check
    mime = getBinaryFileMIMEType(fo);
  } else {
    mime = getKnownBinaryFileMIMETypeByExtension(file.getPath());
  }
  return mime != null ? mime : "content/unknown"; // NOI18N
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

private static Set<DataObject> createProjectWithSubprojectsFromTemplate(InputStream templateResourceStream, FileObject parentFolderLocation, FileObject mainProjectLocation, FileObject[] subProjectLocations, ProjectGenerator.ProjectParameters prjParams) throws IOException {
  List<DataObject> set = new ArrayList<>();
  unzip(templateResourceStream, parentFolderLocation);
  addToSet(set, mainProjectLocation, prjParams, prjParams.getProjectName());
  if (subProjectLocations != null) {
    for (int i = 0; i < subProjectLocations.length; i++) {
      addToSet(set, subProjectLocations[i], prjParams, null);
    }
  }
  FileObject prjLoc = CndFileUtils.toFileObject(prjParams.getProjectFolder());
  customPostProcessProject(prjLoc, prjParams.getProjectName(), prjParams);
  return new LinkedHashSet<>(set);
}
origin: org.netbeans.api/org-netbeans-modules-cnd-gizmo

public boolean showSource(SourceFileInfo lineInfo, boolean isReadOnly) {
  FileObject fo = CndFileUtils.toFileObject(CndFileUtils.normalizeAbsolutePath(lineInfo.getFileName()));
  try {
    new ROEditor(fo).open();
  } catch (DataObjectNotFoundException e) {
    e.printStackTrace();
    return false;
  }
  return true;
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-api-remote

public static FileObject getFileObject(String absolutePath, ExecutionEnvironment execEnv) {
  CndUtils.assertAbsolutePathInConsole(absolutePath, "path for must be absolute"); //NOI18N
  if (execEnv.isRemote()) {
    if (CndUtils.isDebugMode()) {
      String normalizedPath = normalizeAbsolutePath(absolutePath, execEnv);
      if (! normalizedPath.equals(absolutePath)) {
        CndUtils.assertTrueInConsole(false, "Warning: path is not normalized:  absolute path is _" + absolutePath + "_ normailzed path is _"  + normalizedPath + "_");
      }
      //absolutePath = normalizedPath;
    }
    return FileSystemProvider.getFileSystem(execEnv).findResource(absolutePath); //NOI18N
  } else {
    return CndFileUtils.toFileObject(absolutePath);
  }
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

@Override
public CharSequence getSourceProjectName(NativeProject project) {
  if (!(project instanceof NativeProjectProvider)) {
    return null;
  }        
  //parse path_mapper.properties file to get map
  FileObject projectDir = CndFileUtils.toFileObject(project.getFileSystem(), project.getProjectRoot());
  ProjectMapper projectMapper = get(projectDir);
  if (projectMapper == null || projectMapper.getSourceProjectName() == null) {
    return project.getProjectRoot();
  }        
  //here we are
  return projectMapper.getSourceProjectName();
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

public static FileObject getFileObject(String path, WizardDescriptor wizardDescriptor) {
  if (isFullRemote(wizardDescriptor)) {
    String hostUID = (String) wizardDescriptor.getProperty(WizardConstants.PROPERTY_HOST_UID);
    CndUtils.assertNotNull(hostUID, "Null host UID"); //NOI18N
    ExecutionEnvironment env = ExecutionEnvironmentFactory.fromUniqueID(hostUID);
    return RemoteFileUtil.getFileObject(path, env);
  } else {
    return CndFileUtils.toFileObject(CndFileUtils.normalizeAbsolutePath(path));
  }
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

  @Override
  public CharSequence getDestinationPath(NativeProject project, CharSequence sourceFilePath) {
    if (!(project instanceof NativeProjectProvider)) {
      return null;
    }
    /*
    */        
    //here we are
    //what we can have here:
    //1. project is dest project already and SourceFilePath is /export1/tmp/LLVM33
//parse path_mapper.properties file to get map
    FileObject projectDir = CndFileUtils.toFileObject(project.getFileSystem(), project.getProjectRoot());
    ProjectMapper projectMapper = get(projectDir);
    if (projectMapper == null || projectMapper.getDestinationFilePath(sourceFilePath) == null) {
      return sourceFilePath;
    }
    return projectMapper.getDestinationFilePath(sourceFilePath);
  }

origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

  protected final void initDataObjects() {
    ProjectBase prj = getProject();
    if (prj != null) {
      Set<CsmFile> allFiles = new HashSet<>(prj.getAllFiles());
      for (CsmProject lib : prj.getLibraries()) {
        allFiles.addAll(lib.getAllFiles());
      }
      for (CsmFile csmFile : allFiles) {
        if (csmFile instanceof FileImpl) {
          try {
            FileImpl impl = (FileImpl) csmFile;
            NativeFileItem item = impl.getNativeFileItem();
            FileObject fo = (item == null) ? CndFileUtils.toFileObject(impl.getAbsolutePath()) : item.getFileObject();
            DataObject dobj = (fo == null || !fo.isValid()) ? null : DataObject.find(fo);
            //if (dobj == null){
            //    System.err.println("no DO for " + item + " of file " + impl);
            //}
            NativeProjectProvider.registerItemInDataObject(dobj, item);
          } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
          }
        } else {
          System.err.println("unexpected file " + csmFile);
        }
      }
    }
  }
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

public void destroyImpl() throws IOException {
  final Folder aFolder = getFolder();
  if (!aFolder.isDiskFolder()) {
    return;
  }
  String absPath = CndPathUtilities.toAbsolutePath(aFolder.getConfigurationDescriptor().getBaseDirFileObject(), aFolder.getRootPath());
  FileObject folderFileObject = CndFileUtils.toFileObject(aFolder.getConfigurationDescriptor().getBaseDirFileSystem(), absPath);
  if (folderFileObject == null /*paranoia*/ || !folderFileObject.isValid() || !folderFileObject.isFolder()) {
    return;
  }
  folderFileObject.delete();
  Folder parent = aFolder.getParent();
  if (parent != null) {
    parent.removeFolderAction(aFolder);
  }
  super.destroy();
}

org.netbeans.modules.cnd.utils.cacheCndFileUtilstoFileObject

Popular methods of CndFileUtils

  • isLocalFileSystem
  • normalizeAbsolutePath
  • getLocalFileSystem
  • createLocalFile
  • normalizeFile
    normalize file
  • fileObjectToUrl
  • getFileSeparatorChar
  • isExistingFile
    Tests whether the file exists and not directory. One of file or filePath must be not null
  • normalizePath
  • urlToFileObject
  • areFilenamesEqual
  • getCanonicalFileObject
  • areFilenamesEqual,
  • getCanonicalFileObject,
  • getCanonicalPath,
  • isExistingDirectory,
  • isSystemCaseSensitive,
  • toFSPathList,
  • toFile,
  • changeStringCaseIfNeeded,
  • clearFileExistenceCache

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • onRequestPermissionsResult (Fragment)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now