FileUtils { public static boolean isFilePathTooLong(@NonNull String fileName, @NonNull File directory) { if (isFileNameTooLong(fileName)) { return true; } int filePathLength = new File(directory, fileName).getAbsolutePath().length(); if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS) { return filePathLength > 260; } else { return filePathLength > 4096; } } private  FileUtils(); static void deletePath(@NonNull final File path); static void deleteDirectoryContents(@NonNull final File directory); static void cleanOutputDir(@NonNull File path); static void copyFile(@NonNull File from, @NonNull File to); static void copyDirectory(@NonNull File from, @NonNull File to); static void copyFileToDirectory(@NonNull final File from, @NonNull final File to); static void copyDirectoryToDirectory(@NonNull final File from, @NonNull final File to); static void copyDirectoryContentToDirectory(
            @NonNull final File from, @NonNull final File to); @NonNull static File mkdirs(@NonNull File folder); static void delete(@NonNull File file); static void deleteIfExists(@NonNull File file); static void renameTo(@NonNull File file, @NonNull File to); @NonNull static File join(@NonNull File dir, @NonNull String... paths); @NonNull static File join(@NonNull File dir, @NonNull Iterable<String> paths); @NonNull static String join(@NonNull String... paths); @NonNull static String join(@NonNull Iterable<String> paths); @NonNull static String loadFileWithUnixLineSeparators(@NonNull File file); @NonNull static String relativePath(@NonNull File file, @NonNull File dir); @NonNull static String relativePossiblyNonExistingPath(@NonNull File file, @NonNull File dir); @NonNull static String toSystemDependentPath(@NonNull String path); @NonNull static String toSystemIndependentPath(@NonNull String path); @NonNull static String sha1(@NonNull File file); @NonNull static FluentIterable<File> getAllFiles(@NonNull File dir); @NonNull static String getNamesAsCommaSeparatedList(@NonNull Iterable<File> files); @NonNull static String getDirectoryNameForJar(@NonNull File inputFile); static void createFile(@NonNull File file, @NonNull String content); static List<File> find(@NonNull File base, @NonNull final Pattern pattern); static Optional<File> find(@NonNull File base, @NonNull final String name); @NonNull static byte[] readSegment(@NonNull File file, long start, int length); @NonNull static String joinFilePaths(@NonNull Iterable<File> files); @NonNull static String getValidFileName(
            @NonNull String baseName, @NonNull String extension, @NonNull File directory); static boolean isFileNameTooLong(@NonNull String fileName); static boolean isFilePathTooLong(@NonNull String fileName, @NonNull File directory);  }
@Test public void testIsFilePathTooLong() throws IOException { File directory = new File("/Users/foo"); assertFalse(FileUtils.isFilePathTooLong("bar", directory)); assertFalse(FileUtils.isFilePathTooLong(Strings.repeat("a", 255), directory)); assertTrue(FileUtils.isFilePathTooLong(Strings.repeat("a", 256), directory)); if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS) { assertFalse( FileUtils.isFilePathTooLong( "foo.txt", new File("C:\\", Strings.repeat("a", 249)))); assertTrue( FileUtils.isFilePathTooLong( "foo.txt", new File("C:\\", Strings.repeat("a", 250)))); } else { assertFalse( FileUtils.isFilePathTooLong( "foo.txt", new File("/", Strings.repeat("a", 4087)))); assertTrue( FileUtils.isFilePathTooLong( "foo.txt", new File("/", Strings.repeat("a", 4088)))); } assertFalse(FileUtils.isFilePathTooLong("bar", new File("C:\\Users\\foo"))); }