Tabnine Logo
CndFileUtils
Code IndexAdd Tabnine to your IDE (free)

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

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

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

public static char getFileSeparatorChar(FileSystem fs) {
  if (isLocalFileSystem(fs)) {
    return File.separatorChar;
  } else {
    return '/'; //NOI18N
  }
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

public FSPath(FileSystem fileSystem, String path) {
  this.fileSystem = fileSystem;
  this.path = CndFileUtils.normalizeAbsolutePath(fileSystem, path);
}
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 List<FSPath> getSystemIncludePaths() {
  return CndFileUtils.toFSPathList(CndFileUtils.getLocalFileSystem(), this.sysIncludes);
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

public static boolean isExistingFile(String filePath) {
  return isExistingFile(getLocalFileSystem(), filePath);
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

private static String changeStringCaseIfNeeded(FileSystem fs, String path) {
  if (isLocalFileSystem(fs)) {
    if (CndFileUtils.isSystemCaseSensitive()) {
      return path;
    } else {
      return path.toLowerCase();
    }
  } else {
    return path; // remote is always case sensitive
  }
}
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

/**
 * In many places, standard sequence is as follows:
 *  - convert path to absolute if need
 *  - normalize it
 *  - find file object
 * In the case of non-local file systems we should delegate it to correspondent file systems.
 */
public static FileObject getFileObject(FileObject baseFileObject, String relativeOrAbsolutePath) {
  FileObject result = FileSystemProvider.getFileObject(baseFileObject, relativeOrAbsolutePath);
  if (result == null) {
    String absRootPath = CndPathUtilities.toAbsolutePath(baseFileObject, relativeOrAbsolutePath);
    try {
      // XXX:fullRemote we use old logic for local and new for remote
      // but remote approach for local gives #197093 -  Exception: null file
      final FileSystem fs = baseFileObject.getFileSystem();
      if (CndFileUtils.isLocalFileSystem(fs)) {
        result = CndFileUtils.toFileObject(CndFileUtils.normalizeAbsolutePath(absRootPath));
      } else {
        result = InvalidFileObjectSupport.getInvalidFileObject(fs, absRootPath);
      }
    } catch (FileStateInvalidException ex) {
      Exceptions.printStackTrace(ex);
      result = InvalidFileObjectSupport.getInvalidFileObject(InvalidFileObjectSupport.getDummyFileSystem(), absRootPath);
    }
  }
  return result;
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-apt

assert debug = true;
if (debug) {
  if (!CndFileUtils.isExistingFile(fileSystem, this.path.toString())) {
    APTUtils.LOG.log(Level.WARNING, "ResolvedPath: isExistingFile failed in {0} for {1}", new Object[]{fileSystem, path});
  if (CndFileUtils.isLocalFileSystem(fileSystem)) {
  if (CndFileUtils.toFileObject(fileSystem, path) == null) {
    APTUtils.LOG.log(Level.WARNING, "ResolvedPath: no FileObject in {0} for {1} FileUtil.toFileObject = {2} second check = {3}", 
        new Object[]{
origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

@Override
public FileSystem getFileSystem() {
  return CndFileUtils.getLocalFileSystem();
}

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

private static FileObject toFileObjectImpl(FileSystem fs, CharSequence absolutePath) {
  if (isLocalFileSystem(fs)) {
    return toFileObject(absolutePath);
  } else {
    return fs.findResource(absolutePath.toString());
origin: org.netbeans.api/org-netbeans-modules-cnd-gizmo

FileObject fo = CndFileUtils.toFileObject(CndFileUtils.normalizeAbsolutePath(fileName));
if (fo == null || ! fo.isValid()) {
  InputStream inputStream = null;
    URI uri = new URI(lineInfo.getFileName());
    if (uri.getScheme() != null && uri.getScheme().equals("file")) { // NOI18N
      fo = CndFileUtils.toFileObject(FileUtil.normalizeFile(new File(uri))); // XXX:fullRemote
      writer.flush();
      writer.close();
      fo = CndFileUtils.toFileObject(CndFileUtils.normalizeFile(tempFile));
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

private static void index(FileSystem fs, String path, ConcurrentMap<String, Flags> files) {
  if (isLocalFileSystem(fs)) {
    File file = new File(path);
    if (CndFileSystemProvider.canRead(path)) {
      CndFileSystemProvider.FileInfo[] listFiles = listFilesImpl(file);
      for (CndFileSystemProvider.FileInfo curFile : listFiles) {
        String absPath = changeStringCaseIfNeeded(fs, curFile.absolutePath);
        if (isWindows) { //  isLocalFS(fs) checked above
          absPath = absPath.replace('/', '\\');
    FileObject file = fs.findResource(path);            
    if (file != null && file.isFolder() && file.canRead()) {
      final char fileSeparatorChar = getFileSeparatorChar(fs);            
      for (FileObject child : file.getChildren()) {
  assert changeStringCaseIfNeeded(fs, path).equals(path);
  files.put(path, Flags.INDEXED_DIRECTORY);
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-toolchain

String includePrefix = cCompiler.getIncludeFilePathPrefix();
File file = new File(includePrefix + absPath1);
if (!CndFileUtils.exists(file) && absPath2 != null) {
  file = new File(includePrefix + absPath2);
if (CndFileUtils.exists(file)) {
  FileObject fo = CndFileUtils.toFileObject(CndFileUtils.normalizeFile(file));
  return fo;
origin: org.netbeans.api/org-netbeans-modules-cnd-gizmo

@Override
public Map<String, File> getBinaryFiles(ExecutionEnvironment env) {
  Map<String, File> result = new HashMap<String, File>();
  if (relativePath != null && localAbsPath != null) {
    result.put(relativePath, CndFileUtils.createLocalFile(localAbsPath)); // NOI18N
  }
  return result;
}

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

try {
  FileSystem fs = dObj.getPrimaryFile().getFileSystem();
  if (!CndFileUtils.isLocalFileSystem(fs)) {
    annotationAttrs.add(new AttrValuePair(ATTR_ANNOTATION_FS,
      CndFileUtils.fileObjectToUrl(fs.getRoot()).toString()));
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
public void fileFolderCreated(FileEvent fe) {
  File file = CndFileUtils.toFile(fe.getFile());
  String path = file.getAbsolutePath();
  String absPath = preparePath(path);
  if (getFilesMap(getLocalFileSystem()).put(absPath, Flags.DIRECTORY) != null) {
    // If there was something in the map already - invalidate it
    invalidateFile(path, absPath);
  }
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

public static boolean exists(File file) {
  return getFlags(getLocalFileSystem(), file.getAbsolutePath(), true).exist;
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

public static String naturalizeSlashes(FileSystem fileSystem, String path) {
  char rightSlash = CndFileUtils.getFileSeparatorChar(fileSystem);
  char wrongSlash = (rightSlash == '/') ? '\\' : '/';
  return path.replace(wrongSlash, rightSlash);
}
org.netbeans.modules.cnd.utils.cacheCndFileUtils

Javadoc

some file utilities used by CND modules due to performance reasons or other

Most used methods

  • isLocalFileSystem
  • normalizeAbsolutePath
  • toFileObject
  • 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
  • urlToFileObject,
  • areFilenamesEqual,
  • getCanonicalFileObject,
  • getCanonicalPath,
  • isExistingDirectory,
  • isSystemCaseSensitive,
  • toFSPathList,
  • toFile,
  • changeStringCaseIfNeeded,
  • clearFileExistenceCache

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • JLabel (javax.swing)
  • JPanel (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Best plugins for Eclipse
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