コード例 #1
0
 private static void fillFileInfo(ExtendedFileInfo fileInfo, FTPFile ftpFile) {
   fileInfo.setExists(true);
   fileInfo.setName(ftpFile.getName());
   fileInfo.setDirectory(ftpFile.isDir());
   fileInfo.setLength(ftpFile.size());
   fileInfo.setLastModified(ftpFile.lastModified() != null ? ftpFile.lastModified().getTime() : 0);
   fileInfo.setOwner(ftpFile.getOwner());
   fileInfo.setGroup(ftpFile.getGroup());
   fileInfo.setPermissions(Policy.permissionsFromString(ftpFile.getPermissions()));
   if (ftpFile.isLink()) {
     fileInfo.setAttribute(EFS.ATTRIBUTE_SYMLINK, true);
     fileInfo.setStringAttribute(EFS.ATTRIBUTE_LINK_TARGET, ftpFile.getLinkedName().trim());
   }
 }
コード例 #2
0
 /* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#fetchFile(org.eclipse.core.runtime.IPath, int, org.eclipse.core.runtime.IProgressMonitor)
  */
 @SuppressWarnings("deprecation")
 @Override
 protected ExtendedFileInfo fetchFile(IPath path, int options, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   try {
     IPath dirPath = path.removeLastSegments(1);
     String name = path.lastSegment();
     FTPFile result = ftpFileCache.get(path);
     if (result == null) {
       FTPFile[] ftpFiles = listFiles(dirPath, monitor);
       for (FTPFile ftpFile : ftpFiles) {
         Date lastModifiedServerInLocalTZ = ftpFile.lastModified();
         if (serverTimeZoneShift != 0 && lastModifiedServerInLocalTZ != null) {
           ftpFile.setLastModified(
               new Date(lastModifiedServerInLocalTZ.getTime() + serverTimeZoneShift));
         }
         if (".".equals(ftpFile.getName())
             || "..".equals(ftpFile.getName())) { // $NON-NLS-1$ //$NON-NLS-2$
           if (Path.ROOT.equals(path) && ".".equals(ftpFile.getName())) { // $NON-NLS-1$
             ftpFile.setName(path.toPortableString());
             ftpFileCache.put(path, ftpFile);
             result = ftpFile;
           }
           continue;
         }
         ftpFileCache.put(dirPath.append(ftpFile.getName()), ftpFile);
         if (name != null && name.equalsIgnoreCase(ftpFile.getName())) {
           result = ftpFile;
         }
       }
     }
     if ((options & IExtendedFileStore.DETAILED) != 0) {
       if (result != null
           && !result.isDir()
           && name != null
           && result.lastModified().getSeconds() == 0) {
         if (serverSupportsFeature("MDTM")) { // $NON-NLS-1$
           changeCurrentDir(dirPath);
           Policy.checkCanceled(monitor);
           try {
             Date lastModifiedLocalTZ = ftpClient.modtime(name);
             if (lastModifiedLocalTZ != null) {
               result.setLastModified(lastModifiedLocalTZ);
             }
           } catch (FTPException e) {
           }
         }
       }
     }
     if (result == null && Path.ROOT.equals(path)) {
       result = new FTPFile(StringUtils.EMPTY, path.toPortableString(), 0, true, new Date(0));
     }
     if (result != null) {
       return createFileInfo(result);
     }
   } catch (FileNotFoundException e) {
     throw e;
   } catch (OperationCanceledException e) {
     throw e;
   } catch (Exception e) {
     // forces one connection retry
     if (connectionRetryCount < 1) {
       connectionRetryCount++;
       testOrConnect(monitor);
       try {
         return fetchFile(path, options, monitor);
       } finally {
         connectionRetryCount = 0;
       }
     } else {
       connectionRetryCount = 0;
       throw new CoreException(
           new Status(
               Status.ERROR,
               FTPPlugin.PLUGIN_ID,
               Messages.FTPConnectionFileManager_fetch_failed,
               e));
     }
   }
   ExtendedFileInfo fileInfo = new ExtendedFileInfo(path.lastSegment());
   fileInfo.setExists(false);
   return fileInfo;
 }