OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 17 | Rev 57 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 25
Line 352... Line 352...
352
            sourceChannel.close();
352
            sourceChannel.close();
353
            destinationChannel.close();
353
            destinationChannel.close();
354
        }
354
        }
355
    }
355
    }
356
 
356
 
-
 
357
    public static void copyFile(File in, File out, final boolean useTime) throws IOException {
-
 
358
        if (!useTime || in.lastModified() != out.lastModified()) {
-
 
359
            copyFile(in, out);
-
 
360
            if (useTime)
-
 
361
                out.setLastModified(in.lastModified());
-
 
362
        }
-
 
363
    }
-
 
364
 
357
    public static void copyDirectory(File in, File out) throws IOException {
365
    public static void copyDirectory(File in, File out) throws IOException {
358
        copyDirectory(in, out, Collections.<String> emptySet());
366
        copyDirectory(in, out, Collections.<String> emptySet());
359
    }
367
    }
360
 
368
 
361
    public static final Set<String> VersionControl = CollectionUtils.createSet(".svn", "CVS");
369
    public static final Set<String> VersionControl = CollectionUtils.createSet(".svn", "CVS");
362
 
370
 
363
    public static void copyDirectory(File in, File out, final Set<String> toIgnore) throws IOException {
371
    public static void copyDirectory(File in, File out, final Set<String> toIgnore) throws IOException {
-
 
372
        copyDirectory(in, out, toIgnore, false);
-
 
373
    }
-
 
374
 
-
 
375
    public static void copyDirectory(File in, File out, final Set<String> toIgnore, final boolean useTime) throws IOException {
364
        if (toIgnore.contains(in.getName()))
376
        if (toIgnore.contains(in.getName()))
365
            return;
377
            return;
366
 
378
 
367
        if (in.isDirectory()) {
379
        if (in.isDirectory()) {
368
            if (!out.exists()) {
380
            if (!out.exists()) {
369
                out.mkdir();
381
                out.mkdir();
370
            }
382
            }
371
 
383
 
372
            String[] children = in.list();
384
            String[] children = in.list();
373
            for (int i = 0; i < children.length; i++) {
385
            for (int i = 0; i < children.length; i++) {
374
                copyDirectory(new File(in, children[i]), new File(out, children[i]), toIgnore);
386
                copyDirectory(new File(in, children[i]), new File(out, children[i]), toIgnore, useTime);
375
            }
387
            }
376
        } else {
388
        } else {
377
            if (!in.getName().equals("Thumbs.db")) {
389
            if (!in.getName().equals("Thumbs.db")) {
378
                copyFile(in, out);
390
                copyFile(in, out, useTime);
379
            }
391
            }
380
        }
392
        }
381
    }
393
    }
382
 
394
 
383
    /**
395
    /**
Line 402... Line 414...
402
 
414
 
403
        // The directory is now empty so delete it
415
        // The directory is now empty so delete it
404
        return dir.delete();
416
        return dir.delete();
405
    }
417
    }
406
 
418
 
-
 
419
    public static void rm_R(File dir) throws IOException {
-
 
420
        if (dir.isDirectory()) {
-
 
421
            for (final File child : dir.listFiles()) {
-
 
422
                rmR(child);
-
 
423
            }
-
 
424
        }
-
 
425
        // The directory is now empty so delete it
-
 
426
        rm(dir);
-
 
427
    }
-
 
428
 
-
 
429
    public static void rm(File f) throws IOException {
-
 
430
        if (f.exists() && !f.delete())
-
 
431
            throw new IOException("cannot delete " + f);
-
 
432
    }
-
 
433
 
407
    public static final File mkdir_p(File dir) throws IOException {
434
    public static final File mkdir_p(File dir) throws IOException {
408
        if (!dir.exists()) {
435
        if (!dir.exists()) {
409
            if (!dir.mkdirs()) {
436
            if (!dir.mkdirs()) {
410
                throw new IOException("cannot create directory " + dir);
437
                throw new IOException("cannot create directory " + dir);
411
            }
438
            }