001/* 002 * Copyright 2011-2012 Stephen Connolly. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.jszip.pseudo.io; 018 019import java.io.File; 020import java.io.FileInputStream; 021import java.io.FileOutputStream; 022import java.io.IOException; 023import java.io.InputStream; 024import java.io.OutputStream; 025 026public class AliasFilePseudoFile extends PseudoFile { 027 028 private final File delegate; 029 private final String name; 030 031 public AliasFilePseudoFile(PseudoFile parent, File delegate, String name) { 032 super(parent); 033 this.delegate = delegate; 034 this.name = name; 035 } 036 037 /** 038 * {@inheritDoc} 039 */ 040 public boolean canRead() { 041 return delegate.canRead(); 042 } 043 044 /** 045 * {@inheritDoc} 046 */ 047 public boolean canWrite() { 048 return delegate.canWrite(); 049 } 050 051 /** 052 * {@inheritDoc} 053 */ 054 public boolean createNewFile() throws IOException { 055 return delegate.createNewFile(); 056 } 057 058 /** 059 * {@inheritDoc} 060 */ 061 public boolean delete() { 062 return delegate.delete(); 063 } 064 065 /** 066 * {@inheritDoc} 067 */ 068 public boolean renameTo(PseudoFile dest) { 069 return false; 070 } 071 072 /** 073 * {@inheritDoc} 074 */ 075 public boolean exists() { 076 return delegate.exists(); 077 } 078 079 /** 080 * {@inheritDoc} 081 */ 082 public boolean isDirectory() { 083 return delegate.isDirectory(); 084 } 085 086 /** 087 * {@inheritDoc} 088 */ 089 public long lastModified() { 090 return delegate.lastModified(); 091 } 092 093 /** 094 * {@inheritDoc} 095 */ 096 public String getName() { 097 return name; 098 } 099 100 /** 101 * {@inheritDoc} 102 */ 103 public boolean setLastModified(long time) { 104 return delegate.setLastModified(time); 105 } 106 107 /** 108 * {@inheritDoc} 109 */ 110 InputStream $newInputStream() throws IOException { 111 return new FileInputStream(delegate); 112 } 113 114 /** 115 * {@inheritDoc} 116 */ 117 OutputStream $newOutputStream() throws IOException { 118 return new FileOutputStream(delegate); 119 } 120 121 /** 122 * {@inheritDoc} 123 */ 124 OutputStream $newOutputStream(boolean append) throws IOException { 125 return new FileOutputStream(delegate, append); 126 } 127 128 /** 129 * {@inheritDoc} 130 */ 131 public boolean isFile() { 132 return delegate.isFile(); 133 } 134 135 /** 136 * {@inheritDoc} 137 */ 138 public boolean mkdir() { 139 return delegate.mkdir(); 140 } 141 142 /** 143 * {@inheritDoc} 144 */ 145 public void deleteOnExit() { 146 delegate.deleteOnExit(); 147 } 148 149 /** 150 * {@inheritDoc} 151 */ 152 public boolean mkdirs() { 153 return delegate.mkdirs(); 154 } 155 156 /** 157 * {@inheritDoc} 158 */ 159 public boolean isHidden() { 160 return delegate.isHidden(); 161 } 162 163 /** 164 * {@inheritDoc} 165 */ 166 public long length() { 167 return delegate.length(); 168 } 169 170}