@Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        if(directory.isRoot()) {
            final AttributedList<Path> list = new AttributedList<>();
            for(RootFolder root : session.roots()) {
                switch(root.getRootFolderType()) {
                    case 0: // My Files
                    case 1: // Common
                        list.add(new Path(directory, PathNormalizer.name(root.getName()), EnumSet.of(Path.Type.directory, Path.Type.volume),
                                attributes.toAttributes(root)));
                        break;
                }
                listener.chunk(directory, list);
            }
            return list;
        }
        else {
            try {
                final AttributedList<Path> children = new AttributedList<>();
                int pageIndex = 0;
                int fileCount = 0;
                FileContents files;
                do {
                    files = new FilesApi(this.session.getClient()).filesGetById(URIEncoder.encode(fileid.getFileId(directory)),
                            pageIndex,
                            chunksize,
                            "Name asc",
                            0, // All
                            true,
                            false,
                            false
                    );
                    for(File f : files.getFiles()) {
                        final PathAttributes attrs = attributes.toAttributes(f);
                        final EnumSet<Path.Type> type = (f.getFlags() & 1) == 1 ?
                                EnumSet.of(Path.Type.directory) :
                                EnumSet.of(Path.Type.file);
                        children.add(new Path(directory, f.getName(), type, attrs));
                    }
                    pageIndex++;
                    fileCount += files.getFiles().size();
                    listener.chunk(directory, children);
                }
                while(fileCount < files.getTotalRowCount());
                return children;
            }
            catch(ApiException e) {
                throw new StoregateExceptionMappingService(fileid).map("Listing directory {0} failed", e, directory);
            }
        }
    }
@Test
    public void testListWithHiddenFile() throws Exception {
        final StoregateIdProvider nodeid = new StoregateIdProvider(session);
        final Path room = new Path("/My files", EnumSet.of(Path.Type.directory, Path.Type.volume));
        final Path folder = new StoregateDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path file = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        final TransferStatus status = new TransferStatus();
        status.setHidden(true);
        new StoregateTouchFeature(session, nodeid).touch(file, status);
        final AttributedList<Path> list = new StoregateListService(session, nodeid).list(folder, new IndexedListProgressListener() {
            @Override
            public void message(final String message) {
                //
            }

            @Override
            public void visit(final AttributedList<Path> list, final int index, final Path file) {
                if(file.attributes().isHidden()) {
                    list.remove(index);
                }
            }
        });
        assertNotSame(AttributedList.emptyList(), list);
        assertTrue(list.isEmpty());
        new StoregateDeleteFeature(session, nodeid).delete(Arrays.asList(file, folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }