ftpxf.java
来自「JavaExplorer是一个独立于平台的浏览器」· Java 代码 · 共 151 行
JAVA
151 行
/** * File and FTP Explorer * Copyright 2002 * BOESCH Vincent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */package javaexplorer.manager.ftp;import javaexplorer.ftp.*;import objectxml.*;import java.io.*;import java.util.*;import javaexplorer.Launcher;import javaexplorer.model.*;import javaexplorer.ressource.*;import javaexplorer.util.*;import javaexplorer.util.comparator.XFileComparator;import javaexplorer.util.filter.*;import javaexplorer.util.ftp.Ftp;import javaexplorer.util.options.*;import java.nio.channels.*;public class FtpXF implements XFile { static int count = 0; private File _file = null; private Ftp _ftpData = null; private boolean _isDir = false; private boolean _canRead = true; private boolean _canWrite = true; private transient Launcher _launcher = null; private long _length = -1; private FtpXF _parent = null; private String _path = null; private XFileBuffer children = null; /** * Constructeur sans argument, utilise par la xmlization */ public FtpXF() { } /** * Constructeur objet FtpXF * *@param ftp Description of the Parameter *@param path Description of the Parameter *@param isDir Description of the Parameter */ public FtpXF(Ftp ftp, String path, boolean isDir) { this(ftp, path, -1, isDir, true, true); } /** * Constructeur objet FtpXF * *@param ftp Description of the Parameter *@param path Description of the Parameter *@param length Description of the Parameter *@param isDir Description of the Parameter */ public FtpXF(Ftp ftp, String path, long length, boolean isDir, boolean forRead, boolean forWrite) { _ftpData = ftp; _path = (path == null) ? "/" : path; _isDir = isDir; _length = length; _canRead = forRead; _canWrite = forWrite; if (_isDir && (!_path.equals("/")) && (_path.endsWith("/"))) { _path = _path.substring(0, _path.length() - 1); } } /** * Constructeur objet FtpXF * *@param ef Description of the Parameter *@param name Description of the Parameter *@param isDir Description of the Parameter */ public FtpXF(XFile ef, String name, boolean isDir) { _ftpData = ((FtpXF) ef)._ftpData; _isDir = isDir; _path = ((FtpXF) ef)._path; if (!_path.equals("/")) { _path += "/"; } _path += name; } /** *@param destinationDir Description of * the Parameter */ public void copyTo(XFile destinationDir) { _launcher.getXUtil().copyTo(this, destinationDir); } /** *@param ftpb Description of the Parameter *@param path Description of the Parameter *@param isDir Description of the Parameter *@return Description of the Return * Value */ private boolean deleteRecursiveFtp(FtpClient ftpb, String path, boolean isDir) { if (_launcher.getFileModel().needsStopPerform()) { return false; } try { if (!isDir) { ftpb.remove(path); } else { FtpElement[] flr = ftpb.getDirectory(path); if( flr != null ){ for( int i = 0; i < flr.length; i++ ){ int type = flr[i].getType(); String childName = flr[i].getName(); if (!(childName.equals(".") || childName.equals(".."))) { deleteRecursiveFtp(ftpb, _path + "/" + childName, (type == FtpElement.DIR)); } } } //Tous les fichiers r閏ursifs ont 閠
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?