Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. package org.eclipse.jgit.util;
  44. import java.io.File;
  45. import java.io.IOException;
  46. import java.nio.file.Files;
  47. import org.eclipse.jgit.util.FS.Attributes;
  48. /**
  49. * File utilities using Java 7 NIO2
  50. */
  51. @Deprecated
  52. public class FileUtil {
  53. /**
  54. * @param path
  55. * @return target path of the symlink
  56. * @throws IOException
  57. * @deprecated use {@link FileUtils#readSymLink(File)} instead
  58. */
  59. @Deprecated
  60. public static String readSymlink(File path) throws IOException {
  61. return FileUtils.readSymLink(path);
  62. }
  63. /**
  64. * @param path
  65. * path of the symlink to be created
  66. * @param target
  67. * target of the symlink to be created
  68. * @throws IOException
  69. * @deprecated use {@link FileUtils#createSymLink(File, String)} instead
  70. */
  71. @Deprecated
  72. public static void createSymLink(File path, String target)
  73. throws IOException {
  74. FileUtils.createSymLink(path, target);
  75. }
  76. /**
  77. * @param path
  78. * @return {@code true} if the passed path is a symlink
  79. * @deprecated Use {@link Files#isSymbolicLink(java.nio.file.Path)} instead
  80. */
  81. @Deprecated
  82. public static boolean isSymlink(File path) {
  83. return FileUtils.isSymlink(path);
  84. }
  85. /**
  86. * @param path
  87. * @return lastModified attribute for given path
  88. * @throws IOException
  89. * @deprecated Use
  90. * {@link Files#getLastModifiedTime(java.nio.file.Path, java.nio.file.LinkOption...)}
  91. * instead
  92. */
  93. @Deprecated
  94. public static long lastModified(File path) throws IOException {
  95. return FileUtils.lastModified(path);
  96. }
  97. /**
  98. * @param path
  99. * @param time
  100. * @throws IOException
  101. * @deprecated Use
  102. * {@link Files#setLastModifiedTime(java.nio.file.Path, java.nio.file.attribute.FileTime)}
  103. * instead
  104. */
  105. @Deprecated
  106. public static void setLastModified(File path, long time) throws IOException {
  107. FileUtils.setLastModified(path, time);
  108. }
  109. /**
  110. * @param path
  111. * @return {@code true} if the given path exists
  112. * @deprecated Use
  113. * {@link Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
  114. * instead
  115. */
  116. @Deprecated
  117. public static boolean exists(File path) {
  118. return FileUtils.exists(path);
  119. }
  120. /**
  121. * @param path
  122. * @return {@code true} if the given path is hidden
  123. * @throws IOException
  124. * @deprecated Use {@link Files#isHidden(java.nio.file.Path)} instead
  125. */
  126. @Deprecated
  127. public static boolean isHidden(File path) throws IOException {
  128. return FileUtils.isHidden(path);
  129. }
  130. /**
  131. * @param path
  132. * @param hidden
  133. * @throws IOException
  134. * @deprecated Use {@link FileUtils#setHidden(File,boolean)} instead
  135. */
  136. @Deprecated
  137. public static void setHidden(File path, boolean hidden) throws IOException {
  138. FileUtils.setHidden(path, hidden);
  139. }
  140. /**
  141. * @param path
  142. * @return length of the given file
  143. * @throws IOException
  144. * @deprecated Use {@link FileUtils#getLength(File)} instead
  145. */
  146. @Deprecated
  147. public static long getLength(File path) throws IOException {
  148. return FileUtils.getLength(path);
  149. }
  150. /**
  151. * @param path
  152. * @return {@code true} if the given file a directory
  153. * @deprecated Use
  154. * {@link Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
  155. * instead
  156. */
  157. @Deprecated
  158. public static boolean isDirectory(File path) {
  159. return FileUtils.isDirectory(path);
  160. }
  161. /**
  162. * @param path
  163. * @return {@code true} if the given file is a file
  164. * @deprecated Use
  165. * {@link Files#isRegularFile(java.nio.file.Path, java.nio.file.LinkOption...)}
  166. * instead
  167. */
  168. @Deprecated
  169. public static boolean isFile(File path) {
  170. return FileUtils.isFile(path);
  171. }
  172. /**
  173. * @param path
  174. * @return {@code true} if the given file can be executed
  175. * @deprecated Use {@link FileUtils#canExecute(File)} instead
  176. */
  177. @Deprecated
  178. public static boolean canExecute(File path) {
  179. return FileUtils.canExecute(path);
  180. }
  181. /**
  182. * @param path
  183. * @throws IOException
  184. * @deprecated use {@link FileUtils#delete(File)}
  185. */
  186. @Deprecated
  187. public static void delete(File path) throws IOException {
  188. FileUtils.delete(path);
  189. }
  190. /**
  191. * @param fs
  192. * @param path
  193. * @return file system attributes for the given file
  194. * @deprecated Use {@link FileUtils#getFileAttributesPosix(FS,File)} instead
  195. */
  196. @Deprecated
  197. public static Attributes getFileAttributesPosix(FS fs, File path) {
  198. return FileUtils.getFileAttributesPosix(fs, path);
  199. }
  200. /**
  201. * @param file
  202. * @return on Mac: NFC normalized {@link File}, otherwise the passed file
  203. * @deprecated Use {@link FileUtils#normalize(File)} instead
  204. */
  205. @Deprecated
  206. public static File normalize(File file) {
  207. return FileUtils.normalize(file);
  208. }
  209. /**
  210. * @param name
  211. * @return on Mac: NFC normalized form of given name
  212. * @deprecated Use {@link FileUtils#normalize(String)} instead
  213. */
  214. @Deprecated
  215. public static String normalize(String name) {
  216. return FileUtils.normalize(name);
  217. }
  218. }