public FileObject getFileObject() { // using fileSystem.findResource is not safe, see #196425 - AssertionError: no FileObject return CndFileUtils.toFileObject(fileSystem, path); }
@Override public FileObject getFileObject() { return CndFileUtils.toFileObject(file); // XXX:FileObject conversion }
@Override protected boolean mimeAccept(File f) { return mimeAccept(CndFileUtils.toFileObject(f)); }
public static DataObject getDataObject(File file) { CndUtils.assertNormalized(file); return getDataObject(CndFileUtils.toFileObject(file)); }
@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; }
@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; }
private static FileObject findFileObject(String fileName, FileSystem fs) { CndUtils.assertAbsolutePathInConsole(fileName); String normPath = FileSystemProvider.normalizeAbsolutePath(fileName, fs); return CndFileUtils.toFileObject(fs, normPath); }
@Override public FileObject getFileObject() { FileObject fo = CndFileUtils.toFileObject(project.getFileSystem(), normalizedAbsPath); if (fo == null) { fo = InvalidFileObjectSupport.getInvalidFileObject(project.getFileSystem(), normalizedAbsPath); } return fo; }
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; }
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); }
/** * 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 }
/** * 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 }
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); }
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; }
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); } }
@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(); }
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)); } }
@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); }
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); } } } } }
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(); }