/** {@inheritDoc} */ @Override public Collection<IgfsFile> listFiles(IgfsPath path) { return igfs.listFiles(path); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { clear(igfs, igfsSecondary); assert igfs.listFiles(IgfsPath.ROOT).isEmpty(); }
/** * Test list files routine when the path doesn't exist remotely. * * @throws Exception If failed. */ @Test public void testListFilesPathDoesNotExist() throws Exception { Collection<IgfsFile> paths = null; try { paths = igfs.listFiles(SUBDIR); } catch (IgniteException ignore) { // No-op. } assert paths == null || paths.isEmpty(); }
/** * Test list files routine. * * @throws Exception If failed. */ @Test public void testListFiles() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); Collection<IgfsFile> paths = igfs.listFiles(SUBDIR); assert paths != null; assert paths.size() == 2; Iterator<IgfsFile> iter = paths.iterator(); IgfsFile path1 = iter.next(); IgfsFile path2 = iter.next(); assert (SUBSUBDIR.equals(path1.path()) && FILE.equals(path2.path())) || (FILE.equals(path1.path()) && SUBSUBDIR.equals(path2.path())); }
/** * Test list files routine when the path doesn't exist locally. * * @throws Exception If failed. */ @Test public void testListFilesPathMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); Collection<IgfsFile> paths = igfs.listFiles(SUBDIR); assert paths != null; assert paths.size() == 2; Iterator<IgfsFile> iter = paths.iterator(); IgfsFile path1 = iter.next(); IgfsFile path2 = iter.next(); assert (SUBSUBDIR.equals(path1.path()) && FILE.equals(path2.path())) || (FILE.equals(path1.path()) && SUBSUBDIR.equals(path2.path())); }
/** * Calculates size of directory or file for given ID. * * @param file IGFS File object. * @param sum Summary object that will collect information. * @throws IgniteCheckedException If failed. */ private void summaryRecursive(IgfsFile file, IgfsPathSummary sum) throws IgniteCheckedException { assert file != null; assert sum != null; if (file.isDirectory()) { if (!F.eq(IgfsPath.ROOT, file.path())) sum.directoriesCount(sum.directoriesCount() + 1); for (IgfsFile childFile : listFiles(file.path())) summaryRecursive(childFile, sum); } else { sum.filesCount(sum.filesCount() + 1); sum.totalLength(sum.totalLength() + file.length()); } }
/** * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testListPathForSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); assertTrue(igfs.info(DIR).isDirectory()); Collection<IgfsPath> pathes = igfs.listPaths(DIR); Collection<IgfsFile> files = igfs.listFiles(DIR); assertEquals(1, pathes.size()); assertEquals(1, files.size()); assertEquals("filedest", F.first(pathes).name()); assertEquals("filedest", F.first(files).path().name()); }
/** * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testListPathForSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); assertTrue(igfs.info(DIR).isDirectory()); Collection<IgfsPath> pathes = igfs.listPaths(DIR); Collection<IgfsFile> files = igfs.listFiles(DIR); assertEquals(1, pathes.size()); assertEquals(1, files.size()); assertEquals("filedest", F.first(pathes).name()); assertEquals("filedest", F.first(files).path().name()); }
/** {@inheritDoc} */ @Override public Collection<IgfsFile> listFiles(IgfsPath path) { return igfs.listFiles(path); }
/** * Calculates size of directory or file for given ID. * * @param file IGFS File object. * @param sum Summary object that will collect information. * @throws IgniteCheckedException If failed. */ private void summaryRecursive(IgfsFile file, IgfsPathSummary sum) throws IgniteCheckedException { assert file != null; assert sum != null; if (file.isDirectory()) { if (!F.eq(IgfsPath.ROOT, file.path())) sum.directoriesCount(sum.directoriesCount() + 1); for (IgfsFile childFile : listFiles(file.path())) summaryRecursive(childFile, sum); } else { sum.filesCount(sum.filesCount() + 1); sum.totalLength(sum.totalLength() + file.length()); } }