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.IOException; 020import java.io.InputStream; 021import java.io.OutputStream; 022 023public class ProxyPseudoFile extends PseudoFile { 024 025 private PseudoFile delegate; 026 027 public ProxyPseudoFile(PseudoFile parent, String child) { 028 super(parent); 029 final PseudoFileSystem current = PseudoFileSystem.current(); 030 delegate = current.getPseudoFile(parent.getAbsolutePath() + current.getPathSeparator() + child); 031 } 032 033 public ProxyPseudoFile(String pathname) { 034 super(PseudoFileSystem.current().getPseudoFile(pathname).getParentFile()); 035 delegate = PseudoFileSystem.current().getPseudoFile(pathname); 036 } 037 038 public ProxyPseudoFile(String parent, String child) { 039 super(PseudoFileSystem.current().getPseudoFile(parent)); 040 final PseudoFileSystem current = PseudoFileSystem.current(); 041 delegate = current.getPseudoFile(parent + current.getPathSeparator() + child); 042 } 043 044 /** 045 * {@inheritDoc} 046 */ 047 InputStream $newInputStream() throws IOException { 048 return delegate.$newInputStream(); 049 } 050 051 /** 052 * {@inheritDoc} 053 */ 054 OutputStream $newOutputStream() throws IOException { 055 return delegate.$newOutputStream(); 056 } 057 058 /** 059 * {@inheritDoc} 060 */ 061 OutputStream $newOutputStream(boolean append) throws IOException { 062 return delegate.$newOutputStream(append); 063 } 064 065 /** 066 * {@inheritDoc} 067 */ 068 public boolean canRead() { 069 return delegate.canRead(); 070 } 071 072 /** 073 * {@inheritDoc} 074 */ 075 public boolean canWrite() { 076 return delegate.canWrite(); 077 } 078 079 /** 080 * {@inheritDoc} 081 */ 082 public boolean createNewFile() throws IOException { 083 return delegate.createNewFile(); 084 } 085 086 /** 087 * {@inheritDoc} 088 */ 089 public boolean delete() { 090 return delegate.delete(); 091 } 092 093 /** 094 * {@inheritDoc} 095 */ 096 public void deleteOnExit() { 097 delegate.deleteOnExit(); 098 } 099 100 /** 101 * {@inheritDoc} 102 */ 103 public boolean exists() { 104 return delegate.exists(); 105 } 106 107 /** 108 * {@inheritDoc} 109 */ 110 public String getName() { 111 return delegate.getName(); 112 } 113 114 /** 115 * {@inheritDoc} 116 */ 117 public boolean isDirectory() { 118 return delegate.isDirectory(); 119 } 120 121 /** 122 * {@inheritDoc} 123 */ 124 public boolean isFile() { 125 return delegate.isFile(); 126 } 127 128 /** 129 * {@inheritDoc} 130 */ 131 public boolean isHidden() { 132 return delegate.isHidden(); 133 } 134 135 /** 136 * {@inheritDoc} 137 */ 138 public long lastModified() { 139 return delegate.lastModified(); 140 } 141 142 /** 143 * {@inheritDoc} 144 */ 145 public long length() { 146 return delegate.length(); 147 } 148 149 /** 150 * {@inheritDoc} 151 */ 152 public boolean mkdir() { 153 return delegate.mkdir(); 154 } 155 156 /** 157 * {@inheritDoc} 158 */ 159 public boolean mkdirs() { 160 return delegate.mkdirs(); 161 } 162 163 /** 164 * {@inheritDoc} 165 */ 166 public boolean renameTo(PseudoFile dest) { 167 return delegate.renameTo(dest); 168 } 169 170 /** 171 * {@inheritDoc} 172 */ 173 public boolean setLastModified(long time) { 174 return delegate.setLastModified(time); 175 } 176 177 PseudoFile $unwrap() { 178 return delegate; 179 } 180 181}