@Override
    public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException {
        final SMBSession.DiskShareWrapper share = session.openShare(file);
        try {
            if(file.isDirectory()) {
                try (final Directory entry = share.get().openDirectory(new SMBPathContainerService(session).getKey(file),
                        Collections.singleton(AccessMask.FILE_WRITE_ATTRIBUTES),
                        Collections.singleton(FileAttributes.FILE_ATTRIBUTE_DIRECTORY),
                        Collections.singleton(SMB2ShareAccess.FILE_SHARE_READ),
                        SMB2CreateDisposition.FILE_OPEN,
                        Collections.singleton(SMB2CreateOptions.FILE_DIRECTORY_FILE))) {
                    final FileBasicInformation updatedBasicInformation = new FileBasicInformation(
                            status.getCreated() != null ? FileTime.ofEpochMillis(status.getCreated()) : FileBasicInformation.DONT_SET,
                            FileBasicInformation.DONT_SET,
                            status.getModified() != null ? FileTime.ofEpochMillis(status.getModified()) : FileBasicInformation.DONT_SET,
                            FileBasicInformation.DONT_SET,
                            FileAttributes.FILE_ATTRIBUTE_DIRECTORY.getValue());
                    entry.setFileInformation(updatedBasicInformation);
                }
            }
            else {
                try (final File entry = share.get().openFile(new SMBPathContainerService(session).getKey(file),
                        Collections.singleton(AccessMask.FILE_WRITE_ATTRIBUTES),
                        Collections.singleton(FileAttributes.FILE_ATTRIBUTE_NORMAL),
                        Collections.singleton(SMB2ShareAccess.FILE_SHARE_READ),
                        SMB2CreateDisposition.FILE_OPEN,
                        Collections.singleton(SMB2CreateOptions.FILE_NON_DIRECTORY_FILE))) {
                    final FileBasicInformation updatedBasicInformation = new FileBasicInformation(
                            status.getCreated() != null ? FileTime.ofEpochMillis(status.getCreated()) : FileBasicInformation.DONT_SET,
                            FileBasicInformation.DONT_SET,
                            status.getModified() != null ? FileTime.ofEpochMillis(status.getModified()) : FileBasicInformation.DONT_SET,
                            FileBasicInformation.DONT_SET,
                            FileAttributes.FILE_ATTRIBUTE_NORMAL.getValue());
                    entry.setFileInformation(updatedBasicInformation);
                }
            }
        }
        catch(SMBRuntimeException e) {
            throw new SMBExceptionMappingService().map("Cannot change timestamp of {0}", e, file);
        }
        finally {
            session.releaseShare(share);
        }
    }
@Test
    public void testTimestampFileNotfound() throws Exception {
        final TransferStatus status = new TransferStatus();
        final Path home = new DefaultHomeFinderService(session).find();
        final Path f = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        status.setModified(System.currentTimeMillis());
        assertThrows(NotfoundException.class, () -> new SMBTimestampFeature(session).setTimestamp(f, status));
    }