@Override public AbstractFile getParent() { if(!parentValSet) { FileURL parentFileURL = this.fileURL.getParent(); if(parentFileURL!=null) { parent = FileFactory.getFile(parentFileURL); // Note: parent may be null if it can't be resolved } parentValSet = true; } return parent; }
@Override public AbstractFile getParent() { if(!parentValSet) { FileURL parentURL = fileURL.getParent(); if(parentURL==null) this.parent = null; else { this.parent = FileFactory.getFile(parentURL); } this.parentValSet = true; } return this.parent; }
@Override public AbstractFile getParent() { if(!parentValSet) { FileURL parentURL = fileURL.getParent(); if(parentURL!=null) { parent = FileFactory.getFile(parentURL); // Note: parent may be null if it can't be resolved } // Note: do not make the special smb:// file a parent of smb://host/, this would cause parent unit tests to fail parentValSet = true; } return parent; }
@Override public AbstractFile getParent() { if(!parentSet) { FileURL parentFileURL = this.fileURL.getParent(); if(parentFileURL!=null) { try { parent = FileFactory.getFile(parentFileURL, null, service); } catch(IOException e) { // No parent } } parentSet = true; } return parent; }
@Override public AbstractFile getParent() { // Retrieve parent AbstractFile and cache it if (!parentValueSet) { FileURL parentURL = getURL().getParent(); if(parentURL != null) { parent = FileFactory.getFile(parentURL); // Note: parent may be null if it can't be resolved } parentValueSet = true; } return parent; }
@Override public AbstractFile getParent() { if (parent != null) { return parent; } String rootPath = getRootPath(); if (rootPath.equals(pathInsideVm) || pathInsideVm.equals("/")) { return null; } try { parent = new VSphereFile(fileURL.getParent(), this); } catch (URISyntaxException e) { return null; } catch (IOException e) { return null; } catch (RuntimeFaultFaultMsg e) { return null; } catch (InvalidPropertyFaultMsg e) { return null; } catch (FileFaultFaultMsg e) { return null; } catch (GuestOperationsFaultFaultMsg e) { return null; } catch (InvalidStateFaultMsg e) { return null; } catch (TaskInProgressFaultMsg e) { return null; } return parent; }
@Override public AbstractFile getParent() { // Retrieve the parent AbstractFile instance and cache it if (!parentValueSet) { if(!isRoot()) { FileURL parentURL = getURL().getParent(); if(parentURL != null) { parent = FileFactory.getFile(parentURL); } } parentValueSet = true; } return parent; }
@Override public AbstractFile getParent() { // Retrieve the parent AbstractFile instance and cache it if (!parentValueSet) { if(!isRoot()) { FileURL parentURL = getURL().getParent(); if(parentURL != null) { parent = FileFactory.getFile(parentURL); } } parentValueSet = true; } return parent; }
@Override public AbstractFile getParent() { if(!parentValSet) { FileURL parentFileURL = this.fileURL.getParent(); if(parentFileURL!=null) { try { parent = FileFactory.getFile(parentFileURL, null, createFTPFile(parentFileURL.getFilename(), true)); } catch(IOException e) { // No parent, that's all } } parentValSet = true; } return parent; }
@Override public AbstractFile getCanonicalFile() { if(!isSymlink()) return this; // Create the canonical file instance and cache it if(canonicalFile==null) { // getLink() returns the raw symlink target which can either be an absolute or a relative path. If the path is // relative, preprend the absolute path of the symlink's parent folder. String symlinkTargetPath = file.getLink(); if(!symlinkTargetPath.startsWith("/")) { String parentPath = fileURL.getParent().getPath(); if(!parentPath.endsWith("/")) parentPath += "/"; symlinkTargetPath = parentPath + symlinkTargetPath; } FileURL canonicalURL = (FileURL)fileURL.clone(); canonicalURL.setPath(symlinkTargetPath); canonicalFile = FileFactory.getFile(canonicalURL); } return canonicalFile; }
FileURL parentURL = fileURL.getParent(); LOGGER.trace("fileURL={} parent={}", fileURL, parentURL);
String parentPath = fileURL.getParent().getPath(); if(!parentPath.endsWith("/")) parentPath += "/";
assert "file".equals(url.getFilename()); url = url.getParent(); assert "file".equals(url.getScheme()); assert "localhost".equals(url.getHost()); assert "file".equals(url.getFilename()); url = url.getParent(); assert "file".equals(url.getScheme()); assert "localhost".equals(url.getHost()); assert "to".equals(url.getFilename()); url = url.getParent(); assert "file".equals(url.getScheme()); assert "localhost".equals(url.getHost());
/** * Tests {@link AbstractFile#getParent()} and {@link AbstractFile#isParentOf(AbstractFile)} methods. * * @throws IOException should not happen */ @Test public void testParent() throws IOException { AbstractFile file = tempFile; AbstractFile parent; AbstractFile child; // Tests all parents until the root is reached while((parent=file.getParent())!=null) { assert parent.isParentOf(file); // a file that has a parent shouldn't be a root file assert !file.isRoot(); // Assert that the child file can be resolved into the same file using getDirectChild() child = parent.getDirectChild(file.getName()); assert child != null; assert child.equals(file); file = parent; } // Assert that the root file's parent URL is null: if that is not the case, the parent file should have been // resolved. assert file.getURL().getParent()==null; // A file that has no parent should be a root file assert file.isRoot(); }