/** * Get file name * * @param ext * the file extension * @return name of the file. */ public String getFileName(PackExt ext) { return packName + '.' + ext.getExtension(); }
private File extFile(PackExt ext) { String p = packFile.getName(); int dot = p.lastIndexOf('.'); String b = (dot < 0) ? p : p.substring(0, dot); return new File(packFile.getParentFile(), b + '.' + ext.getExtension()); }
/** {@inheritDoc} */ @Override public String toString() { return String.format("PackExt[%s, bit=0x%s]", getExtension(), //$NON-NLS-1$ Integer.toHexString(getBit())); } }
/** * Returns a PackExt for the file extension and registers it in the values * array. * * @param ext * the file extension. * @return the PackExt for the ext */ public synchronized static PackExt newPackExt(String ext) { PackExt[] dst = new PackExt[VALUES.length + 1]; for (int i = 0; i < VALUES.length; i++) { PackExt packExt = VALUES[i]; if (packExt.getExtension().equals(ext)) return packExt; dst[i] = packExt; } if (VALUES.length >= 32) throw new IllegalStateException( "maximum number of pack extensions exceeded"); //$NON-NLS-1$ PackExt value = new PackExt(ext, VALUES.length); dst[VALUES.length] = value; VALUES = dst; return value; }
/** * {@inheritDoc} * <p> * Add a single existing pack to the list of available pack files. */ @Override public PackFile openPack(File pack) throws IOException { final String p = pack.getName(); if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack")) //$NON-NLS-1$ //$NON-NLS-2$ throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, pack)); // The pack and index are assumed to exist. The existence of other // extensions needs to be explicitly checked. // int extensions = PACK.getBit() | INDEX.getBit(); final String base = p.substring(0, p.length() - 4); for (PackExt ext : PackExt.values()) { if ((extensions & ext.getBit()) == 0) { final String name = base + ext.getExtension(); if (new File(pack.getParentFile(), name).exists()) extensions |= ext.getBit(); } } PackFile res = new PackFile(pack, extensions); insertPack(res); return res; }
for (PackExt ext : extensions) if (PackExt.PACK.equals(ext)) { File f = nameFor(packName, "." + ext.getExtension()); //$NON-NLS-1$ removeOldPack(f, packName, ext, deleteOptions); break; for (PackExt ext : extensions) { if (!PackExt.PACK.equals(ext)) { File f = nameFor(packName, "." + ext.getExtension()); //$NON-NLS-1$ removeOldPack(f, packName, ext, deleteOptions);
int extensions = 0; for (PackExt ext : PackExt.values()) { if (names.contains(base + ext.getExtension())) extensions |= ext.getBit(); final String packName = base + PACK.getExtension(); final PackFile oldPack = forReuse.remove(packName); if (oldPack != null) {
/** * Deletes old pack file, unless 'preserve-oldpacks' is set, in which case it * moves the pack file to the preserved directory * * @param packFile * @param packName * @param ext * @param deleteOptions * @throws IOException */ private void removeOldPack(File packFile, String packName, PackExt ext, int deleteOptions) throws IOException { if (pconfig != null && pconfig.isPreserveOldPacks()) { File oldPackDir = repo.getObjectDatabase().getPreservedDirectory(); FileUtils.mkdir(oldPackDir, true); String oldPackName = "pack-" + packName + ".old-" + ext.getExtension(); //$NON-NLS-1$ //$NON-NLS-2$ File oldPackFile = new File(oldPackDir, oldPackName); FileUtils.rename(packFile, oldPackFile); } else { FileUtils.delete(packFile, deleteOptions); } }
"." + tmpEntry.getKey().getExtension()); //$NON-NLS-1$ try { FileUtils.rename(tmpExt, realExt,
/** * @param ext * the file extension * @return name of the file. */ public String getFileName(PackExt ext) { return packName + '.' + ext.getExtension(); }
/** * Get file name * * @param ext * the file extension * @return name of the file. */ public String getFileName(PackExt ext) { return packName + '.' + ext.getExtension(); }
private File extFile(PackExt ext) { String p = packFile.getName(); int dot = p.lastIndexOf('.'); String b = (dot < 0) ? p : p.substring(0, dot); return new File(packFile.getParentFile(), b + '.' + ext.getExtension()); }
private File extFile(PackExt ext) { String p = packFile.getName(); int dot = p.lastIndexOf('.'); String b = (dot < 0) ? p : p.substring(0, dot); return new File(packFile.getParentFile(), b + '.' + ext.getExtension()); }
/** {@inheritDoc} */ @Override public String toString() { return String.format("PackExt[%s, bit=0x%s]", getExtension(), //$NON-NLS-1$ Integer.toHexString(getBit())); } }
@Override public String toString() { return String.format("PackExt[%s, bit=0x%s]", getExtension(), //$NON-NLS-1$ Integer.toHexString(getBit())); } }
/** * Returns a PackExt for the file extension and registers it in the values * array. * * @param ext * the file extension. * @return the PackExt for the ext */ public synchronized static PackExt newPackExt(String ext) { PackExt[] dst = new PackExt[VALUES.length + 1]; for (int i = 0; i < VALUES.length; i++) { PackExt packExt = VALUES[i]; if (packExt.getExtension().equals(ext)) return packExt; dst[i] = packExt; } if (VALUES.length >= 32) throw new IllegalStateException( "maximum number of pack extensions exceeded"); //$NON-NLS-1$ PackExt value = new PackExt(ext, VALUES.length); dst[VALUES.length] = value; VALUES = dst; return value; }
/** * Returns a PackExt for the file extension and registers it in the values * array. * * @param ext * the file extension. * @return the PackExt for the ext */ public synchronized static PackExt newPackExt(String ext) { PackExt[] dst = new PackExt[VALUES.length + 1]; for (int i = 0; i < VALUES.length; i++) { PackExt packExt = VALUES[i]; if (packExt.getExtension().equals(ext)) return packExt; dst[i] = packExt; } if (VALUES.length >= 32) throw new IllegalStateException( "maximum number of pack extensions exceeded"); //$NON-NLS-1$ PackExt value = new PackExt(ext, VALUES.length); dst[VALUES.length] = value; VALUES = dst; return value; }
for (PackExt ext : PackExt.values()) { if ((extensions & ext.getBit()) == 0) { final String name = base + ext.getExtension(); if (new File(pack.getParentFile(), name).exists()) extensions |= ext.getBit();
/** * {@inheritDoc} * <p> * Add a single existing pack to the list of available pack files. */ @Override public PackFile openPack(File pack) throws IOException { final String p = pack.getName(); if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack")) //$NON-NLS-1$ //$NON-NLS-2$ throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, pack)); // The pack and index are assumed to exist. The existence of other // extensions needs to be explicitly checked. // int extensions = PACK.getBit() | INDEX.getBit(); final String base = p.substring(0, p.length() - 4); for (PackExt ext : PackExt.values()) { if ((extensions & ext.getBit()) == 0) { final String name = base + ext.getExtension(); if (new File(pack.getParentFile(), name).exists()) extensions |= ext.getBit(); } } PackFile res = new PackFile(pack, extensions); insertPack(res); return res; }
/** * Deletes old pack file, unless 'preserve-oldpacks' is set, in which case it * moves the pack file to the preserved directory * * @param packFile * @param packName * @param ext * @param deleteOptions * @throws IOException */ private void removeOldPack(File packFile, String packName, PackExt ext, int deleteOptions) throws IOException { if (pconfig != null && pconfig.isPreserveOldPacks()) { File oldPackDir = repo.getObjectDatabase().getPreservedDirectory(); FileUtils.mkdir(oldPackDir, true); String oldPackName = "pack-" + packName + ".old-" + ext.getExtension(); //$NON-NLS-1$ //$NON-NLS-2$ File oldPackFile = new File(oldPackDir, oldPackName); FileUtils.rename(packFile, oldPackFile); } else { FileUtils.delete(packFile, deleteOptions); } }