public String retrieveVfsPath( String pathToTmp ) throws KettleFileException { FileObject vfsFile = KettleVFS.getFileObject( pathToTmp ); String path = vfsFile.getName().getPath(); return path; }
public static String getFilename( FileObject fileObject ) { FileName fileName = fileObject.getName(); String root = fileName.getRootURI(); if ( !root.startsWith( "file:" ) ) { return fileName.getURI(); } if ( root.endsWith( ":/" ) ) { root = root.substring( 8, 10 ); } else { root = root.substring( 7, root.length() - 1 ); } String fileString = root + fileName.getPath(); if ( !"/".equals( Const.FILE_SEPARATOR ) ) { fileString = Const.replace( fileString, "/", Const.FILE_SEPARATOR ); } return fileString; }
private String calcRepositoryDirectory( KettleFileRepository fileRep, FileObject fileObject ) throws FileSystemException { String path = fileObject.getParent().getName().getPath(); String baseDirectory = fileRep.getRepositoryMeta().getBaseDirectory(); // Double check! // if ( path.startsWith( baseDirectory ) ) { return path.substring( baseDirectory.length() ); } else { return path; } } }
private String calcRepositoryDirectory( KettleFileRepository fileRep, FileObject fileObject ) throws FileSystemException { String path = fileObject.getParent().getName().getPath(); String baseDirectory = fileRep.getRepositoryMeta().getBaseDirectory(); // Double check! // if ( path.startsWith( baseDirectory ) ) { return path.substring( baseDirectory.length() ); } else { return path; } }
private File getFile( final String filename ) { try { String uri = KettleVFS.getFileObject( environmentSubstitute( filename ), this ).getName().getPath(); return new File( uri ); } catch ( KettleFileException ex ) { logError( "Error in Fetching URI for File: " + filename, ex ); } return new File( filename ); }
private static void throwsErrorOnFileNotFound( FileObject file ) throws KettleFileNotFoundException, FileSystemException { if ( file == null || !file.exists() ) { throw new KettleFileNotFoundException( "File not found", file.getName().getPath() ); } }
public static String getFilename( FileObject fileObject ) { FileName fileName = fileObject.getName(); String root = fileName.getRootURI(); if ( !root.startsWith( "file:" ) ) { return fileName.getURI(); // nothing we can do about non-normal files. } if ( root.startsWith( "file:////" ) ) { return fileName.getURI(); // we'll see 4 forward slashes for a windows/smb network share } if ( root.endsWith( ":/" ) ) { // Windows root = root.substring( 8, 10 ); } else { // *nix & OSX root = ""; } String fileString = root + fileName.getPath(); if ( !"/".equals( Const.FILE_SEPARATOR ) ) { fileString = Const.replace( fileString, "/", Const.FILE_SEPARATOR ); } return fileString; }
String filename = file.getName().getPath();
newFilenames.add( fileObject.getName().getPath() );
newFilenames.add( fileObject.getName().getPath() );
@Override protected void execute() throws Exception { FileObject targetDirectory = targetFile.getParent(); FileObjectRepository targetRepository = new FileObjectRepository( targetDirectory ); targetRoot = targetRepository.getRoot(); suffix = getSuffix( targetPath ); Path p = Paths.get( targetFile.getName().getPath() ); filename = IOUtils.getInstance().stripFileExtension( p.getFileName().toString() ); ReportProcessor reportProcessor = createReportProcessor( null ); try { reportProcessor.processReport(); } finally { reportProcessor.close(); } }
newFilenames.add( fileObject.getName().getPath() );
@Override public RepositoryObject getObjectInformation( ObjectId objectId, RepositoryObjectType objectType ) throws KettleException { try { String filename = calcDirectoryName( null ); if ( objectId.getId().startsWith( "/" ) ) { filename += objectId.getId().substring( 1 ); } else { filename += objectId.getId(); } FileObject fileObject = KettleVFS.getFileObject( filename ); if ( !fileObject.exists() ) { return null; } FileName fname = fileObject.getName(); String name = fname.getBaseName(); if ( !Utils.isEmpty( fname.getExtension() ) && name.length() > fname.getExtension().length() ) { name = name.substring( 0, name.length() - fname.getExtension().length() - 1 ); } String filePath = fileObject.getParent().getName().getPath(); final FileObject baseDirObject = KettleVFS.getFileObject( repositoryMeta.getBaseDirectory() ); final int baseDirObjectPathLength = baseDirObject.getName().getPath().length(); final String dirPath = baseDirObjectPathLength <= filePath.length() ? filePath.substring( baseDirObjectPathLength ) : "/"; RepositoryDirectoryInterface directory = loadRepositoryDirectoryTree().findDirectory( dirPath ); Date lastModified = new Date( fileObject.getContent().getLastModifiedTime() ); return new RepositoryObject( objectId, name, directory, "-", lastModified, objectType, "", false ); } catch ( Exception e ) { throw new KettleException( "Unable to get object information for object with id=" + objectId, e ); } }
/** * Initialize for processing specified file. */ protected void init( String file ) throws Exception { FileObject fo = getFile( file ); meta.setDbfFileName( fo.getName().getPath() ); step = new XBaseInput( stepMeta, null, 1, transMeta, trans ); step.init( meta, data ); step.addRowListener( rowListener ); }
boolean unzip = true; String filename = children[i].getName().getPath();
private void exec(FileObject file) { final Oven oven = new Oven(config); oven.bake(new File(file.getName().getPath())); } }
/** * Determines if a file or folder should be selected. * * @param fileInfo The file selection information. * @return true if the file should be selected, false otherwise. */ @Override public boolean includeFile(final FileSelectInfo fileInfo) { return this.pattern.matcher(fileInfo.getFile().getName().getPath()).matches(); }
private static String getDataStoreReferenceForFile(FileObject file) throws DataStoreException, IOException { try{ File f = new File(file.getName().getPath()); return dataStore.store(f.toPath(), dataDir); } catch(Exception e){ throw new DataStoreException("Failure storing file. File path: "+file.getName().getPath(), e); } }