Package jcifs.smb

Examples of jcifs.smb.SmbFile


   * @throws RegainException If the URL's protocol isn't <code>smb://</code>.
   */
  public static SmbFile urlToSmbFile(String url) throws RegainException {

    try {
      return new SmbFile(urlToSmbFileName(url));
    } catch (MalformedURLException urlEx) {
      throw new RegainException(urlEx.getMessage(), urlEx);
    }
  }
View Full Code Here


public class List {

    public static void main( String[] argv ) throws Exception {

        SmbFile file = new SmbFile( argv[0] );

        long t1 = System.currentTimeMillis();
        SmbFile[] files = file.listFiles();
        long t2 = System.currentTimeMillis() - t1;

        for( int i = 0; i < files.length; i++ ) {
            System.out.println( " " + files[i].getURL().toExternalForm()  + " ");
        }
View Full Code Here

   */
  private byte[] loadSmbFile(String url) throws RegainException {
       
    InputStream in = null;
    try {
      SmbFile smbFile = RegainToolkit.urlToSmbFile(
        CrawlerToolkit.replaceAuthenticationValuesInURL(url, mAccountPasswordEntry));
   
      if( smbFile.canRead() && !smbFile.isDirectory() ) {
        in = smbFile.getInputStream();
        mLastModifiedDate = new Date(smbFile.lastModified());
       
        return CrawlerToolkit.loadFileFromStream(in,smbFile.getContentLength());
       
      } else {
        throw new RegainException("Can't load content from: "
        + smbFile.getCanonicalPath());
      }
     
    } catch (Throwable thr) {
      throw new RegainException( thr.getMessage(), thr );
     
View Full Code Here

          throw new RegainException("Creating stream for file failed: " +
              mContentAsFile, thr);
        }
      } else if(mUrl.startsWith("smb://")) {
        try {
           SmbFile smbFile = RegainToolkit.urlToSmbFile(
             CrawlerToolkit.replaceAuthenticationValuesInURL(mUrl, mAccountPasswordEntry));
           return smbFile.getInputStream();
          
        } catch (Throwable thr) {
          throw new RegainException("Creating stream for file failed: " +
              mContentAsFile, thr);
        }
View Full Code Here

          continue;
        }
      } else if (url.startsWith("smb://")) {
        // Windows share: Check whether this is a directory
        try {
          SmbFile smbFile = RegainToolkit.urlToSmbFile(
            CrawlerToolkit.replaceAuthenticationValuesInURL(url,
            CrawlerToolkit.findAuthenticationValuesForURL(url, accountPasswordStore)));
          // Check whether the file is readable.
          if (!smbFile.canRead()) {
            mCrawlerJobProfiler.abortMeasuring();
            logError("File is not readable: '" + url + "'", null, false);
            continue;
          } else if (smbFile.isDirectory()) {
            // This IS a directory -> Add all child files as Jobs
            if (shouldBeParsed) {
              parseSmbDirectory(smbFile);
            }
View Full Code Here

         } else
           path = smbFileName.getUriWithoutAuth();

        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(
            smbFileName.getDomain(), smbFileName.getUserName(), smbFileName.getPassword());
        SmbFile file = new SmbFile(path, auth);

        if (file.isDirectory() && !file.toString().endsWith("/"))
        {
            file = new SmbFile(path + "/", auth);
        }

        return file;
    }
View Full Code Here

    public URL getURL() throws FileSystemException {
      try {
        file = createSmbFile(getName());

        SmbFile parent = new SmbFile(file.getParent());
        SmbFile[] tmp = parent.listFiles(new SmbFileFilter() {
           public boolean accept(SmbFile f) {
             return f.getName().equals(file.getName());
           }
        });
View Full Code Here

     * @throws MalformedURLException
     */
    public SmbFile getSmbFile() throws MalformedURLException {
        if (!isSMB()) throw new UnsupportedOperationException();
        String url = unescape(this.toNormalform(false, true));
        return new SmbFile(url);
    }
View Full Code Here

    }
   
    public String[] list() throws IOException {
        if (isFile()) return getFSFile().list();
        if (isSMB()) try {
            SmbFile sf = getSmbFile();
            if (!sf.isDirectory()) return null;
            try {
                return TimeoutRequest.list(sf, SMB_TIMEOUT);
            } catch (SmbException e) {
                throw new IOException("SMB.list SmbException for " + sf.toString() + ": " + e.getMessage());
            }
        } catch (MalformedURLException e) {
            throw new IOException("SMB.list MalformedURLException for " + this.toString() + ": " + e.getMessage());
        }
        return null;
View Full Code Here

            for (String s: l) {
                if (s.startsWith(".")) continue;
                s = MultiProtocolURI.escape(s).toString();
                if (!s.endsWith("/") && !s.endsWith("\\")) {
                    // check if this is a directory
                    SmbFile sf = new SmbFile(u + s);
                    if (sf.isDirectory()) s = s + "/";
                }
                list.add(u + s);
            }
        
            StringBuilder content = FTPClient.dirhtml(u, null, null, null, list, true);
View Full Code Here

TOP

Related Classes of jcifs.smb.SmbFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.