/** * @deprecated Calling this method is equivalent to * {@link TConfig#getArchiveDetector TConfig.get().getArchiveDetector()}. * @see <a href="http://java.net/jira/browse/TRUEZIP-238">#TRUEZIP-238</a> */ @Deprecated public static TArchiveDetector getDefaultArchiveDetector() { return TConfig.get().getArchiveDetector(); }
/** * Equivalent to * {@link TConfig#getArchiveDetector TConfig.get().getArchiveDetector()}. */ public static TArchiveDetector getDefaultArchiveDetector() { return TConfig.get().getArchiveDetector(); }
/** * Encrypts the given plain file to the given RAES file. * This version uses the default TArchiveDetector to detect any archive * files in its parent directory path except the files themselves, which * are not recognized as archive files. */ public static void encrypt( final String plainFilePath, final String raesFilePath) throws IOException { encrypt(plainFilePath, raesFilePath, TConfig.get().getArchiveDetector()); }
private static TArchiveDetector getDetector(File file) { return file instanceof TFile ? ((TFile) file).getArchiveDetector() : TConfig.get().getArchiveDetector(); } }
/** * Decrypts the given RAES file to the given plain file. * This version uses the default TArchiveDetector to detect any archive * files in its parent directory path except the files themselves, which * are not recognized as archive files. */ public static void decrypt( final String raesFilePath, final String plainFilePath, final boolean strongAuthentication) throws IOException { decrypt(raesFilePath, plainFilePath, strongAuthentication, TConfig.get().getArchiveDetector()); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { parse( FsPath.create((URI) in.readObject(), CANONICALIZE), TConfig.get().getArchiveDetector()); }
/** Copy constructor for inheritable thread local configurations. */ private TConfig(final TConfig template) { this.manager = template.getFsManager(); this.detector = template.getArchiveDetector(); this.inputPreferences = template.getInputPreferences(); this.outputPreferences = template.getOutputPreferences(); }
/** * Constructs a new {@code TFile} instance which may use the given archive * detector to scan the <em>entire path name</em> for prospective archive * files. * * @param parent the parent directory. * @param member the member path name. * @param detector the archive detector to use for scanning the path name * for prospective archive files. * If this parameter is {@code null}, then the * {@linkplain TConfig#getArchiveDetector default archive detector} * is used instead. */ @ExpertFeature(INJECTING_A_DIFFERENT_DETECTOR_FOR_THE_SAME_PATH_MAY_CORRUPT_DATA) public TFile( final @CheckForNull String parent, final String member, final @CheckForNull TArchiveDetector detector) { super(parent, member); this.file = new File(parent, member); this.detector = null != detector ? detector : TConfig.get().getArchiveDetector(); scan(null); assert invariants(); }
/** * Constructs a new {@code TFile} instance which may use the given * {@link TArchiveDetector} to scan its path name for prospective archive * files. * * @param path the path name. * @param detector the archive detector to use for scanning the path name * for prospective archive files. * If this parameter is {@code null}, then the * {@linkplain TConfig#getArchiveDetector default archive detector} * is used instead. */ @ExpertFeature(INJECTING_A_DIFFERENT_DETECTOR_FOR_THE_SAME_PATH_MAY_CORRUPT_DATA) public TFile( final String path, final @CheckForNull TArchiveDetector detector) { super(path); this.file = new File(path); this.detector = null != detector ? detector : TConfig.get().getArchiveDetector(); scan(null); assert invariants(); }
@Override protected TArchiveDetector newArchiveDetector1(String suffix, String password) { return KeyManagement.newArchiveDetector1( TConfig.get().getArchiveDetector(), suffix, password.getBytes(US_ASCII)); }
@Override protected TArchiveDetector newArchiveDetector2(String suffix, String password) { return KeyManagement.newArchiveDetector2( TConfig.get().getArchiveDetector(), suffix, password.toCharArray()); } }
scan(p); } else { this.detector = null != detector ? detector : TConfig.get().getArchiveDetector(); scan(null);
} else { this.file = file; this.detector = null != detector ? detector : TConfig.get().getArchiveDetector(); scan(null);
final @CheckForNull TArchiveDetector detector) { super(path.toHierarchicalUri()); parse(path, null != detector ? detector : TConfig.get().getArchiveDetector());
private static void assertScan(final String... params) throws URISyntaxException { final FsPath parent = new FsPath(new URI(params[0])); final URI member = new URI(params[1]); final FsPath path = new FsPath(new URI(params[2])); final FsMountPoint mountPoint = null == params[3] ? null : new FsMountPoint(new URI(params[3])); final FsPath result = new TPathScanner( TConfig.get().getArchiveDetector()) .scan(parent, member); assertThat(result, equalTo(path)); assertThat(result.getMountPoint(), is(mountPoint)); }
args = lshift(args); final TArchiveDetector oldDetector = TConfig.get().getArchiveDetector(); try {
srcDetector = newArchiveDetector(Charset.forName("UTF-8")); else srcDetector = TConfig.get().getArchiveDetector(); dstDetector = newArchiveDetector(Charset.forName("UTF-8")); else dstDetector = TConfig.get().getArchiveDetector();
private static void assertPathConstructor(final TFile file, final String[] params) { assertThat(file.getArchiveDetector(), is(TConfig.get().getArchiveDetector())); assertThat(file.getPath(), equalTo(params[1].replace('/', separatorChar))); if (null != params[2]) { assertThat(file.getInnerArchive().getPath(), equalTo(params[2].replace('/', separatorChar))); } else { assertThat(file.getInnerArchive(), nullValue()); } if (null != params[3]) { assertThat(file.getEnclArchive().getPath(), equalTo(params[3].replace('/', separatorChar))); assertThat(file.getEnclEntryName(), equalTo(params[4])); } else { assertThat(file.getEnclArchive(), nullValue()); assertThat(file.getEnclEntryName(), nullValue()); } assertThat(new TFile(file.toFsPath()), equalTo(file.getNormalizedAbsoluteFile())); assertThat(new TFile(file.toURI()), equalTo(file.getAbsoluteFile())); }
@Test public void defaults() { final TConfig c = TConfig.get(); assertThat(TConfig.get(), sameInstance(c)); final TArchiveDetector detector = c.getArchiveDetector(); assertThat(detector, sameInstance(TArchiveDetector.ALL)); assertThat(c.getArchiveDetector(), sameInstance(detector)); final boolean lenient = c.isLenient(); assertThat(lenient, is(true)); assertThat(c.isLenient(), is(lenient)); assertTrue(c.getInputPreferences().isEmpty()); assertThat(c.getOutputPreferences(), is(BitField.of(CREATE_PARENTS))); }
final TConfig c1 = TConfig.get(); assertThat(TConfig.get(), sameInstance(c1)); final TArchiveDetector ad1 = c1.getArchiveDetector(); assertThat(c1.getArchiveDetector(), sameInstance(ad1)); final TArchiveDetector ad2 = new TArchiveDetector("mok", d); final TConfig c2 = TConfig.push(); c2.setArchiveDetector(ad2); assertThat(TConfig.get(), sameInstance(c2)); assertThat(c2.getArchiveDetector(), sameInstance(ad2)); final TArchiveDetector ad3 = new TArchiveDetector("mok", d); final TConfig c3 = TConfig.push(); c3.setArchiveDetector(ad3); assertThat(TConfig.get(), sameInstance(c3)); assertThat(c3.getArchiveDetector(), sameInstance(ad3)); } finally { c3.close(); assertThat(c2.getArchiveDetector(), sameInstance(ad2)); } finally { c2.close(); assertThat(c1.getArchiveDetector(), sameInstance(ad1));