当前位置: 首页>>代码示例>>Java>>正文


Java SmbException类代码示例

本文整理汇总了Java中jcifs.smb.SmbException的典型用法代码示例。如果您正苦于以下问题:Java SmbException类的具体用法?Java SmbException怎么用?Java SmbException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SmbException类属于jcifs.smb包,在下文中一共展示了SmbException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDirectory

import jcifs.smb.SmbException; //导入依赖的package包/类
@Override
public void createDirectory(boolean createParentWhenNotExists) throws IOException {
	SmbFile file= _file(true);
	if (file == null) throw new IOException("SMBFile is inaccessible");
	ResourceUtil.checkCreateDirectoryOK(this, createParentWhenNotExists);
	try {
		provider.lock(this);
		file.mkdir();
	} catch (SmbException e) {
		throw new IOException(e); // for cfcatch type="java.io.IOException"
	}
	finally {
		provider.unlock(this);
	}
	
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:17,代码来源:SMBResource.java

示例2: performListing

import jcifs.smb.SmbException; //导入依赖的package包/类
private Set<SmbFile> performListing(final SmbFile directory2, final boolean recurseSubdirectories) throws SmbException {
    if (!directory2.canRead() || !directory2.canWrite()) {
        throw new IllegalStateException("Directory '" + directory2 + "' does not have sufficient permissions (i.e., not writable and readable)");
    }
    final Set<SmbFile> queue = new HashSet<SmbFile>();
    if (!directory2.exists()) {
        return queue;
    }

    final SmbFile[] children = directory2.listFiles();
    if (children == null) {
        return queue;
    }

    for (final SmbFile child : children) {
        if (child.isDirectory()) {
            if (recurseSubdirectories) {
                queue.addAll(performListing(child,  recurseSubdirectories));
            }
        } else  {
            queue.add(child);
        }
    }

    return queue;
}
 
开发者ID:dream-lab,项目名称:echo,代码行数:27,代码来源:GetSmbFiles.java

示例3: lastModified

import jcifs.smb.SmbException; //导入依赖的package包/类
public long lastModified() throws MalformedURLException, SmbException {
    switch (mode) {
        case SFTP:
            SshClientUtils.execute(new SFtpClientTemplate(path) {
                @Override
                public Long execute(SFTPClient client) throws IOException {
                    return client.mtime(SshClientUtils.extractRemotePathFrom(path));
                }
            });
            break;
        case SMB:
            SmbFile smbFile = getSmbFile();
            if (smbFile != null)
                return smbFile.lastModified();
            break;
        case FILE:
            new File(path).lastModified();
            break;
        case ROOT:
            HybridFileParcelable baseFile = generateBaseFileFromParent();
            if (baseFile != null)
                return baseFile.getDate();
    }
    return new File("/").lastModified();
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:26,代码来源:HybridFile.java

示例4: main

import jcifs.smb.SmbException; //导入依赖的package包/类
public static void main( String argv[] ) throws Exception
{
    if (argv.length < 2) {
        System.err.println("usage: TestListLoop <smburl> <count>");
        System.exit(0);
    }

    int count = Integer.parseInt(argv[1]);

    for ( ;; ) {
        try {
            SmbFile f = new SmbFile(argv[0]);
            SmbFile[] list = f.listFiles();
            System.out.println("Successfully listed resource: " + list.length);
        } catch (SmbException se) {
            se.printStackTrace();
        }

        if (--count <= 0)
            break;

        Thread.sleep( 1000 );
    }
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:25,代码来源:TestListLoop.java

示例5: testDeleteLocked

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
public void testDeleteLocked () throws IOException {
    String fname = makeRandomName();
    try ( SmbFile sr = getDefaultShareRoot();
          SmbResource exclFile = new SmbFile(sr, fname) ) {

        try ( OutputStream s = exclFile.openOutputStream(false, SmbConstants.FILE_NO_SHARE) ) {
            try {
                exclFile.delete();
                fail("Could remove locked file");
            }
            catch ( SmbException e ) {
                if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) {
                    return;
                }
                throw e;
            }
        }
        finally {
            exclFile.delete();
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:24,代码来源:ConcurrencyTest.java

示例6: testOpenLocked

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
public void testOpenLocked () throws IOException {
    String fname = makeRandomName();
    try ( SmbFile sr = getDefaultShareRoot();
          SmbResource exclFile = new SmbFile(sr, fname) ) {

        try ( OutputStream s = exclFile.openOutputStream(false, SmbConstants.FILE_NO_SHARE);
              InputStream is = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE) ) {}
        catch ( SmbException e ) {
            if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) {
                return;
            }
            throw e;
        }
        finally {
            exclFile.delete();
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:20,代码来源:ConcurrencyTest.java

示例7: testNoLeakRequestError

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
@Ignore
// BUG #14
public void testNoLeakRequestError () throws IOException {
    try ( SmbResource f = getDefaultShareRoot().resolve("doesnotexist") ) {
        try ( SmbTreeHandleInternal th = (SmbTreeHandleInternal) ( (SmbFile) f ).getTreeHandle();
              SmbSessionInternal sess = th.getSession().unwrap(SmbSessionInternal.class);
              SmbTransportInternal t = (SmbTransportInternal) sess.getTransport() ) {

            assertEquals(0, t.getInflightRequests());
            try ( InputStream is = f.openInputStream() ) {

            }
            catch ( SmbException e ) {
                // expected
            }
            assertEquals(0, t.getInflightRequests());
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:21,代码来源:SessionTest.java

示例8: runReadWriteTest

import jcifs.smb.SmbException; //导入依赖的package包/类
private void runReadWriteTest ( int bufSize, long length ) throws MalformedURLException, UnknownHostException, SmbException, IOException {
    try ( SmbFile f = createTestFile() ) {
        try {
            try ( OutputStream os = f.getOutputStream() ) {
                writeRandom(bufSize, length, os);
            }

            assertEquals("File size matches", length, f.length());

            try ( InputStream is = f.getInputStream() ) {
                verifyRandom(bufSize, length, is);
            }

        }
        finally {
            f.delete();
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:20,代码来源:ReadWriteTest.java

示例9: testTransactPipe

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
public void testTransactPipe () throws IOException {
    try ( SmbNamedPipe f = new SmbNamedPipe(
        getTransactPipeUrl(),
        SmbPipeResource.PIPE_TYPE_RDWR | SmbPipeResource.PIPE_TYPE_TRANSACT,
        withTestNTLMCredentials(getContext())) ) {
        try ( SmbPipeHandle p = f.openPipe() ) {
            try ( OutputStream os = p.getOutput() ) {
                writeRandom(1024, 1024, os);
                try ( InputStream is = p.getInput() ) {
                    verifyRandom(1024, 1024, is);
                }
            }
        }
        catch ( SmbException e ) {
            if ( e.getNtStatus() == 0xC00000BB ) {
                Assume.assumeTrue("Server does not support pipes or it does not exist", false);
            }
            throw e;
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:23,代码来源:ReadWriteTest.java

示例10: testCallPipe

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
public void testCallPipe () throws IOException {
    try ( SmbNamedPipe f = new SmbNamedPipe(
        getCallPipeUrl(),
        SmbPipeResource.PIPE_TYPE_RDWR | SmbPipeResource.PIPE_TYPE_CALL,
        withTestNTLMCredentials(getContext())) ) {
        try ( SmbPipeHandle p = f.openPipe() ) {
            try ( OutputStream os = p.getOutput() ) {
                writeRandom(1024, 1024, os);
                try ( InputStream is = p.getInput() ) {
                    verifyRandom(1024, 1024, is);
                }
            }
        }
        catch ( SmbException e ) {
            if ( e.getNtStatus() == 0xC00000BB ) {
                Assume.assumeTrue("Server does not support pipes or it does not exist", false);
            }
            throw e;
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:23,代码来源:ReadWriteTest.java

示例11: testFifoPipe

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
public void testFifoPipe () throws IOException {
    try ( SmbNamedPipe f = new SmbNamedPipe(getFifoPipeUrl(), SmbPipeResource.PIPE_TYPE_RDWR, withTestNTLMCredentials(getContext())) ) {
        try ( SmbPipeHandle p = f.openPipe() ) {
            try ( OutputStream os = p.getOutput() ) {
                writeRandom(1024, 1024, os);
                try ( InputStream is = p.getInput() ) {
                    verifyRandom(1024, 1024, is);
                }
            }
        }
        catch ( SmbException e ) {
            if ( e.getNtStatus() == 0xC0000034 ) {
                Assume.assumeTrue("Server does not support pipes or it does not exist", false);
            }
            throw e;
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:20,代码来源:ReadWriteTest.java

示例12: testFifoPipeTwoHandles

import jcifs.smb.SmbException; //导入依赖的package包/类
@Test
public void testFifoPipeTwoHandles () throws IOException {
    try ( SmbNamedPipe s = new SmbNamedPipe(getFifoPipeUrl(), SmbPipeResource.PIPE_TYPE_WRONLY, withTestNTLMCredentials(getContext()));
          SmbNamedPipe t = new SmbNamedPipe(getFifoPipeUrl(), SmbPipeResource.PIPE_TYPE_RDONLY, withTestNTLMCredentials(getContext())) ) {
        try ( SmbPipeHandle sp = s.openPipe();
              SmbPipeHandle tp = t.openPipe() ) {
            try ( OutputStream os = sp.getOutput() ) {
                writeRandom(1024, 1024, os);
            }
            try ( InputStream is = tp.getInput() ) {
                verifyRandom(1024, 1024, is);
            }
        }
        catch ( SmbException e ) {
            if ( e.getNtStatus() == 0xC0000034 ) {
                Assume.assumeTrue("Server does not support pipes or it does not exist", false);
            }
            throw e;
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:22,代码来源:ReadWriteTest.java

示例13: listMedia

import jcifs.smb.SmbException; //导入依赖的package包/类
@Override
public SambaMedia[] listMedia() {
    ArrayList<SambaMedia> list = new ArrayList<>();
    try {
        SmbFile[] files = super.listFiles();
        for (SmbFile file : files) {
            if (!file.getName().contains(":")) {
                list.add(new SambaMedia(file));
            }
        }
    } catch (SmbException | MalformedURLException | UnknownHostException e) {
        e.printStackTrace();
    }
    Collections.sort(list);
    return list.toArray(new SambaMedia[list.size()]);
}
 
开发者ID:xdtianyu,项目名称:Gallery,代码行数:17,代码来源:SambaMedia.java

示例14: children

import jcifs.smb.SmbException; //导入依赖的package包/类
@Override
public synchronized List<SambaMedia> children() {

    if (children.size() == 0) {
        try {
            SmbFile[] files = super.listFiles();
            for (SmbFile file : files) {
                if (!file.getName().contains(":")) {
                    SambaMedia media = new SambaMedia(file);
                    media.setParent(this);
                    children.add(media);

                    if (!hasImage) {
                        if (media.isImage()) {
                            hasImage = true;
                        }
                    }
                }
            }
        } catch (SmbException | MalformedURLException | UnknownHostException e) {
            e.printStackTrace();
        }
        Collections.sort(children);
    }
    return Collections.unmodifiableList(children);
}
 
开发者ID:xdtianyu,项目名称:Gallery,代码行数:27,代码来源:SambaMedia.java

示例15: serveDir

import jcifs.smb.SmbException; //导入依赖的package包/类
private Response serveDir(SmbFile file) throws SmbException, UnknownHostException {
    final String canonicalPath = file.getCanonicalPath();
    if (!canonicalPath.endsWith("/")) {
        // MX Player can't handle redirect
        try {
            file = new SmbFile(file, canonicalPath + "/");
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }

    final SmbFile[] list = file.listFiles();
    StringBuilder sb = new StringBuilder();
    for (SmbFile f : list) {
        final String name = f.getName();
        sb.append(String.format("<a href=\"%s\">%s</a><br>", Uri.encode(name), name));
    }

    return newFixedLengthResponse(Response.Status.OK, MIME_HTML + "; charset=UTF-8",
            sb.toString());
}
 
开发者ID:CzBiX,项目名称:SMB-Steamer,代码行数:22,代码来源:HttpServer.java


注:本文中的jcifs.smb.SmbException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。