comparison src/org/tmatesoft/hg/internal/FileUtils.java @ 707:42b88709e41d

Merge: support 'unresolved' resolution with MergeStateBuilder
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 16 Aug 2013 19:22:59 +0200
parents b4242b7e7dfe
children
comparison
equal deleted inserted replaced
706:cd5c87d96315 707:42b88709e41d
23 import java.io.FileInputStream; 23 import java.io.FileInputStream;
24 import java.io.FileOutputStream; 24 import java.io.FileOutputStream;
25 import java.io.IOException; 25 import java.io.IOException;
26 import java.io.InputStream; 26 import java.io.InputStream;
27 import java.nio.channels.FileChannel; 27 import java.nio.channels.FileChannel;
28 import java.util.Arrays;
29 import java.util.LinkedList;
30 import java.util.List;
28 31
29 import org.tmatesoft.hg.core.HgIOException; 32 import org.tmatesoft.hg.core.HgIOException;
30 import org.tmatesoft.hg.util.LogFacility; 33 import org.tmatesoft.hg.util.LogFacility;
31 import org.tmatesoft.hg.util.LogFacility.Severity; 34 import org.tmatesoft.hg.util.LogFacility.Severity;
32 35
126 } 129 }
127 } 130 }
128 } 131 }
129 132
130 // nothing special, just a single place with common prefix 133 // nothing special, just a single place with common prefix
131 public File createTempFile() throws IOException { 134 public static File createTempFile() throws IOException {
132 return File.createTempFile("hg4j-", null); 135 return File.createTempFile("hg4j-", null);
133 } 136 }
137
138 public static void rmdir(File dest) throws IOException {
139 if (!dest.isDirectory()) {
140 return;
141 }
142 LinkedList<File> queue = new LinkedList<File>();
143 queue.addAll(Arrays.asList(dest.listFiles()));
144 while (!queue.isEmpty()) {
145 File next = queue.removeFirst();
146 if (next.isDirectory()) {
147 List<File> files = Arrays.asList(next.listFiles());
148 if (!files.isEmpty()) {
149 queue.addAll(files);
150 queue.add(next);
151 }
152 // fall through
153 }
154 next.delete();
155 }
156 dest.delete();
157 }
158
134 } 159 }