View Javadoc
1   /*
2    * Copyright (C) 2012, Robin Rosenberg <robin.rosenberg@dewire.com>
3    * and other copyright owners as documented in the project's IP log.
4    *
5    * This program and the accompanying materials are made available
6    * under the terms of the Eclipse Distribution License v1.0 which
7    * accompanies this distribution, is reproduced below, and is
8    * available at http://www.eclipse.org/org/documents/edl-v10.php
9    *
10   * All rights reserved.
11   *
12   * Redistribution and use in source and binary forms, with or
13   * without modification, are permitted provided that the following
14   * conditions are met:
15   *
16   * - Redistributions of source code must retain the above copyright
17   *   notice, this list of conditions and the following disclaimer.
18   *
19   * - Redistributions in binary form must reproduce the above
20   *   copyright notice, this list of conditions and the following
21   *   disclaimer in the documentation and/or other materials provided
22   *   with the distribution.
23   *
24   * - Neither the name of the Eclipse Foundation, Inc. nor the
25   *   names of its contributors may be used to endorse or promote
26   *   products derived from this software without specific prior
27   *   written permission.
28   *
29   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
30   * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
31   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
32   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34   * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42   */
43  
44  package org.eclipse.jgit.util;
45  
46  import java.io.File;
47  import java.io.IOException;
48  import java.nio.file.Files;
49  
50  import org.eclipse.jgit.util.FS.Attributes;
51  
52  /**
53   * File utilities using Java 7 NIO2
54   */
55  @Deprecated
56  public class FileUtil {
57  
58  	/**
59  	 * @param path
60  	 * @return target path of the symlink
61  	 * @throws IOException
62  	 * @deprecated use {@link FileUtils#readSymLink(File)} instead
63  	 */
64  	@Deprecated
65  	public static String readSymlink(File path) throws IOException {
66  		return FileUtils.readSymLink(path);
67  	}
68  
69  	/**
70  	 * @param path
71  	 *            path of the symlink to be created
72  	 * @param target
73  	 *            target of the symlink to be created
74  	 * @throws IOException
75  	 * @deprecated use {@link FileUtils#createSymLink(File, String)} instead
76  	 */
77  	@Deprecated
78  	public static void createSymLink(File path, String target)
79  			throws IOException {
80  		FileUtils.createSymLink(path, target);
81  	}
82  
83  	/**
84  	 * @param path
85  	 * @return {@code true} if the passed path is a symlink
86  	 * @deprecated Use {@link Files#isSymbolicLink(java.nio.file.Path)} instead
87  	 */
88  	@Deprecated
89  	public static boolean isSymlink(File path) {
90  		return FileUtils.isSymlink(path);
91  	}
92  
93  	/**
94  	 * @param path
95  	 * @return lastModified attribute for given path
96  	 * @throws IOException
97  	 * @deprecated Use
98  	 *             {@link Files#getLastModifiedTime(java.nio.file.Path, java.nio.file.LinkOption...)}
99  	 *             instead
100 	 */
101 	@Deprecated
102 	public static long lastModified(File path) throws IOException {
103 		return FileUtils.lastModified(path);
104 	}
105 
106 	/**
107 	 * @param path
108 	 * @param time
109 	 * @throws IOException
110 	 * @deprecated Use
111 	 *             {@link Files#setLastModifiedTime(java.nio.file.Path, java.nio.file.attribute.FileTime)}
112 	 *             instead
113 	 */
114 	@Deprecated
115 	public static void setLastModified(File path, long time) throws IOException {
116 		FileUtils.setLastModified(path, time);
117 	}
118 
119 	/**
120 	 * @param path
121 	 * @return {@code true} if the given path exists
122 	 * @deprecated Use
123 	 *             {@link Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
124 	 *             instead
125 	 */
126 	@Deprecated
127 	public static boolean exists(File path) {
128 		return FileUtils.exists(path);
129 	}
130 
131 	/**
132 	 * @param path
133 	 * @return {@code true} if the given path is hidden
134 	 * @throws IOException
135 	 * @deprecated Use {@link Files#isHidden(java.nio.file.Path)} instead
136 	 */
137 	@Deprecated
138 	public static boolean isHidden(File path) throws IOException {
139 		return FileUtils.isHidden(path);
140 	}
141 
142 	/**
143 	 * @param path
144 	 * @param hidden
145 	 * @throws IOException
146 	 * @deprecated Use {@link FileUtils#setHidden(File,boolean)} instead
147 	 */
148 	@Deprecated
149 	public static void setHidden(File path, boolean hidden) throws IOException {
150 		FileUtils.setHidden(path, hidden);
151 	}
152 
153 	/**
154 	 * @param path
155 	 * @return length of the given file
156 	 * @throws IOException
157 	 * @deprecated Use {@link FileUtils#getLength(File)} instead
158 	 */
159 	@Deprecated
160 	public static long getLength(File path) throws IOException {
161 		return FileUtils.getLength(path);
162 	}
163 
164 	/**
165 	 * @param path
166 	 * @return {@code true} if the given file a directory
167 	 * @deprecated Use
168 	 *             {@link Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
169 	 *             instead
170 	 */
171 	@Deprecated
172 	public static boolean isDirectory(File path) {
173 		return FileUtils.isDirectory(path);
174 	}
175 
176 	/**
177 	 * @param path
178 	 * @return {@code true} if the given file is a file
179 	 * @deprecated Use
180 	 *             {@link Files#isRegularFile(java.nio.file.Path, java.nio.file.LinkOption...)}
181 	 *             instead
182 	 */
183 	@Deprecated
184 	public static boolean isFile(File path) {
185 		return FileUtils.isFile(path);
186 	}
187 
188 	/**
189 	 * @param path
190 	 * @return {@code true} if the given file can be executed
191 	 * @deprecated Use {@link FileUtils#canExecute(File)} instead
192 	 */
193 	@Deprecated
194 	public static boolean canExecute(File path) {
195 		return FileUtils.canExecute(path);
196 	}
197 
198 	/**
199 	 * @param path
200 	 * @throws IOException
201 	 * @deprecated use {@link FileUtils#delete(File)}
202 	 */
203 	@Deprecated
204 	public static void delete(File path) throws IOException {
205 		FileUtils.delete(path);
206 	}
207 
208 	/**
209 	 * @param fs
210 	 * @param path
211 	 * @return file system attributes for the given file
212 	 * @deprecated Use {@link FileUtils#getFileAttributesPosix(FS,File)} instead
213 	 */
214 	@Deprecated
215 	public static Attributes getFileAttributesPosix(FS fs, File path) {
216 		return FileUtils.getFileAttributesPosix(fs, path);
217 	}
218 
219 	/**
220 	 * @param file
221 	 * @return on Mac: NFC normalized {@link File}, otherwise the passed file
222 	 * @deprecated Use {@link FileUtils#normalize(File)} instead
223 	 */
224 	@Deprecated
225 	public static File normalize(File file) {
226 		return FileUtils.normalize(file);
227 	}
228 
229 	/**
230 	 * @param name
231 	 * @return on Mac: NFC normalized form of given name
232 	 * @deprecated Use {@link FileUtils#normalize(String)} instead
233 	 */
234 	@Deprecated
235 	public static String normalize(String name) {
236 		return FileUtils.normalize(name);
237 	}
238 
239 }