protected VirtualFile createDirInCommand(final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(myProject) {
+ @Override
protected void run() throws Throwable {
try {
- VirtualFile dir = parent.createChildDirectory(this, name);
+ VirtualFile dir = parent.findChild(name);
+ if (dir == null) {
+ dir = parent.createChildDirectory(this, name);
+ }
result.set(dir);
}
catch (IOException e) {
}.execute();
}
+ protected void editFileInCommand(final VirtualFile file, final String newContent) {
+ editFileInCommand(myProject, file, newContent);
+ }
+
public static void editFileInCommand(final Project project, final VirtualFile file, final String newContent) {
new WriteCommandAction.Simple(project) {
+ @Override
protected void run() throws Throwable {
try {
file.setBinaryContent(newContent.getBytes());