@Override public String getName() { String fileName = file.getName(); // Windows: drive letter is needed. If filename is empty, we are on a root folder return (OperatingSystemUtils.isWindows() && fileName.length() == 0) ? file.getPath() : fileName; }
/** * Get the path of the logged in user's home directory. */ public static String getUserHomePath() { return getUserHomeDir().getAbsolutePath(); }
/** * Replace instances of internal tokens with actual file equivalents. */ public static String canonicalize(String target) { if (target.startsWith(Files.HOME_ALIAS)) { String homePath = OperatingSystemUtils.getUserHomePath(); target = homePath + target.substring(1, target.length()); } return target; }
child = OperatingSystemUtils.getSafeFilename(child); Files.copyDirectory(resource, new File(addonSlotDir, child));
public static MutableAddonRepository forDefaultDirectory(Forge forge) { return new AddonRepositoryImpl(forge.getLockManager(), new File(OperatingSystemUtils.getUserHomePath(), DEFAULT_ADDON_DIR)); }
private static boolean _deleteRecursive(final File file, final boolean collect) { if (collect && OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } if (file == null) { return false; } File[] children = file.listFiles(); if (children != null) { for (File sf : children) { if (sf.isDirectory()) { _deleteRecursive(sf, false); } else { if (!sf.delete()) { throw new RuntimeException("failed to delete: " + sf.getAbsolutePath()); } } } } return file.delete(); }
/** * Get the logged in user's Forge directory. */ public static File getUserForgeDir() { return new File(getUserHomeDir(), ".forge").getAbsoluteFile(); }
public static boolean delete(File file, final boolean recursive) { if (recursive) { if (_deleteRecursive(file, true)) { return true; } return false; } if ((file.listFiles() != null) && (file.listFiles().length != 0)) { throw new RuntimeException("directory not empty"); } if (OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } file.deleteOnExit(); // be paranoid if (file.delete()) { return true; } return false; }
private static boolean _deleteRecursive(final File file, final boolean collect) { if (collect && OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } if (file == null) { return false; } File[] children = file.listFiles(); if (children != null) { for (File sf : children) { if (sf.isDirectory()) { _deleteRecursive(sf, false); } else { if (!sf.delete()) { throw new RuntimeException("failed to delete: " + sf.getAbsolutePath()); } } } } return file.delete(); }
/** * Delete this {@link Resource}, and all child resources. */ @Override public boolean delete(final boolean recursive) { if (recursive) { if (_deleteRecursive(file, true)) { resourceFactory.fireEvent(new ResourceDeleted(this)); return true; } return false; } if ((file.listFiles() != null) && (file.listFiles().length != 0)) { throw new RuntimeException("directory not empty"); } if (OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } if (file.delete()) { resourceFactory.fireEvent(new ResourceDeleted(this)); return true; } return false; }
if (OperatingSystemUtils.isWindows())