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
49 import org.eclipse.jgit.util.FS.Attributes;
50
51 /**
52 * File utilities using Java 7 NIO2
53 */
54 @Deprecated
55 public class FileUtil {
56
57 /**
58 * Read target path of a symlink.
59 *
60 * @param path
61 * a {@link java.io.File}.
62 * @return target path of the symlink.
63 * @throws java.io.IOException
64 * @deprecated use {@link org.eclipse.jgit.util.FileUtils#readSymLink(File)}
65 * instead
66 */
67 @Deprecated
68 public static String readSymlink(File path) throws IOException {
69 return FileUtils.readSymLink(path);
70 }
71
72 /**
73 * Create a symlink
74 *
75 * @param path
76 * path of the symlink to be created
77 * @param target
78 * target of the symlink to be created
79 * @throws java.io.IOException
80 * @deprecated use
81 * {@link org.eclipse.jgit.util.FileUtils#createSymLink(File, String)}
82 * instead
83 */
84 @Deprecated
85 public static void createSymLink(File path, String target)
86 throws IOException {
87 FileUtils.createSymLink(path, target);
88 }
89
90 /**
91 * Whether the passed file is a symlink
92 *
93 * @param path
94 * a {@link java.io.File} object.
95 * @return {@code true} if the passed path is a symlink
96 * @deprecated Use
97 * {@link java.nio.file.Files#isSymbolicLink(java.nio.file.Path)}
98 * instead
99 */
100 @Deprecated
101 public static boolean isSymlink(File path) {
102 return FileUtils.isSymlink(path);
103 }
104
105 /**
106 * Get lastModified attribute for given path
107 *
108 * @param path
109 * a {@link java.io.File}.
110 * @return lastModified attribute for given path
111 * @throws java.io.IOException
112 * @deprecated Use
113 * {@link java.nio.file.Files#getLastModifiedTime(java.nio.file.Path, java.nio.file.LinkOption...)}
114 * instead
115 */
116 @Deprecated
117 public static long lastModified(File path) throws IOException {
118 return FileUtils.lastModified(path);
119 }
120
121 /**
122 * Set lastModified attribute for given path
123 *
124 * @param path
125 * a {@link java.io.File}.
126 * @param time
127 * a long.
128 * @throws java.io.IOException
129 * @deprecated Use
130 * {@link java.nio.file.Files#setLastModifiedTime(java.nio.file.Path, java.nio.file.attribute.FileTime)}
131 * instead
132 */
133 @Deprecated
134 public static void setLastModified(File path, long time) throws IOException {
135 FileUtils.setLastModified(path, time);
136 }
137
138 /**
139 * Whether this file exists
140 *
141 * @param path
142 * a {@link java.io.File}.
143 * @return {@code true} if the given path exists
144 * @deprecated Use
145 * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
146 * instead
147 */
148 @Deprecated
149 public static boolean exists(File path) {
150 return FileUtils.exists(path);
151 }
152
153 /**
154 * Whether this file is hidden
155 *
156 * @param path
157 * a {@link java.io.File}.
158 * @return {@code true} if the given path is hidden
159 * @throws java.io.IOException
160 * @deprecated Use {@link java.nio.file.Files#isHidden(java.nio.file.Path)}
161 * instead
162 */
163 @Deprecated
164 public static boolean isHidden(File path) throws IOException {
165 return FileUtils.isHidden(path);
166 }
167
168 /**
169 * Set this file hidden
170 *
171 * @param path
172 * a {@link java.io.File}.
173 * @param hidden
174 * a boolean.
175 * @throws java.io.IOException
176 * @deprecated Use
177 * {@link org.eclipse.jgit.util.FileUtils#setHidden(File,boolean)}
178 * instead
179 */
180 @Deprecated
181 public static void setHidden(File path, boolean hidden) throws IOException {
182 FileUtils.setHidden(path, hidden);
183 }
184
185 /**
186 * Get file length
187 *
188 * @param path
189 * a {@link java.io.File}.
190 * @return length of the given file
191 * @throws java.io.IOException
192 * @deprecated Use {@link org.eclipse.jgit.util.FileUtils#getLength(File)}
193 * instead
194 */
195 @Deprecated
196 public static long getLength(File path) throws IOException {
197 return FileUtils.getLength(path);
198 }
199
200 /**
201 * Whether the given File is a directory
202 *
203 * @param path
204 * a {@link java.io.File} object.
205 * @return {@code true} if the given file is a directory
206 * @deprecated Use
207 * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
208 * instead
209 */
210 @Deprecated
211 public static boolean isDirectory(File path) {
212 return FileUtils.isDirectory(path);
213 }
214
215 /**
216 * Whether the given File is a file
217 *
218 * @param path
219 * a {@link java.io.File} object.
220 * @return {@code true} if the given file is a file
221 * @deprecated Use
222 * {@link java.nio.file.Files#isRegularFile(java.nio.file.Path, java.nio.file.LinkOption...)}
223 * instead
224 */
225 @Deprecated
226 public static boolean isFile(File path) {
227 return FileUtils.isFile(path);
228 }
229
230 /**
231 * Whether the given file can be executed
232 *
233 * @param path
234 * a {@link java.io.File} object.
235 * @return {@code true} if the given file can be executed
236 * @deprecated Use {@link org.eclipse.jgit.util.FileUtils#canExecute(File)}
237 * instead
238 */
239 @Deprecated
240 public static boolean canExecute(File path) {
241 return FileUtils.canExecute(path);
242 }
243
244 /**
245 * Delete the given file
246 *
247 * @param path
248 * a {@link java.io.File} object.
249 * @throws java.io.IOException
250 * @deprecated use {@link org.eclipse.jgit.util.FileUtils#delete(File)}
251 */
252 @Deprecated
253 public static void delete(File path) throws IOException {
254 FileUtils.delete(path);
255 }
256
257 /**
258 * Get file system attributes for the given file
259 *
260 * @param fs
261 * a {@link org.eclipse.jgit.util.FS} object.
262 * @param path
263 * a {@link java.io.File} object.
264 * @return file system attributes for the given file
265 * @deprecated Use
266 * {@link org.eclipse.jgit.util.FileUtils#getFileAttributesPosix(FS,File)}
267 * instead
268 */
269 @Deprecated
270 public static Attributes getFileAttributesPosix(FS fs, File path) {
271 return FileUtils.getFileAttributesPosix(fs, path);
272 }
273
274 /**
275 * NFC normalize File (on Mac), otherwise do nothing
276 *
277 * @param file
278 * a {@link java.io.File}.
279 * @return on Mac: NFC normalized {@link java.io.File}, otherwise the passed
280 * file
281 * @deprecated Use {@link org.eclipse.jgit.util.FileUtils#normalize(File)}
282 * instead
283 */
284 @Deprecated
285 public static File normalize(File file) {
286 return FileUtils.normalize(file);
287 }
288
289 /**
290 * NFC normalize file name (on Mac), otherwise do nothing
291 *
292 * @param name
293 * a {@link java.lang.String} object.
294 * @return on Mac: NFC normalized form of given name
295 * @deprecated Use {@link org.eclipse.jgit.util.FileUtils#normalize(String)}
296 * instead
297 */
298 @Deprecated
299 public static String normalize(String name) {
300 return FileUtils.normalize(name);
301 }
302
303 }