openwrt

setenv serverip 192.168.1.11
tftp 0x80060000 openwrt-new3.bin
erase 0x9f030000 +$filesize 
cp.b $fileaddr 0x9f030000 $filesize
erase 0x9f680000  +0x100

 

	// 说明:-1不存在文件或目录 0-文件 1-目录
	public static int getFileType(FTPClient client, String dir) throws Exception
	{
		FTPFile[] files = null;
		try
		{
			files = client.list(dir);
		} catch (Exception e)
		{
			return -1;
		}
		if (files.length > 1)
		{
			return FTPFile.TYPE_DIRECTORY;
		} else if (files.length == 1)
		{
			FTPFile f = files[0];
			if (f.getType() == FTPFile.TYPE_DIRECTORY)
			{
				return FTPFile.TYPE_DIRECTORY;
			}
			String path = dir + "/" + f.getName();
			try
			{
				int len = client.list(path).length;
				if (len == 1)
				{
					return FTPFile.TYPE_DIRECTORY;
				} else
				{
					return FTPFile.TYPE_FILE;
				}
			} catch (Exception e)
			{
				return FTPFile.TYPE_FILE;
			}
		} else
		{
			try
			{
				client.changeDirectory(dir);
				client.changeDirectoryUp();
				return FTPFile.TYPE_DIRECTORY;
			} catch (Exception e)
			{
				return -1;
			}
		}
	}

 

你可能感兴趣的:(openwrt)