Lines 19-24
Link Here
|
19 |
|
19 |
|
20 |
package org.netbeans.modules.masterfs.filebasedfs.fileobjects; |
20 |
package org.netbeans.modules.masterfs.filebasedfs.fileobjects; |
21 |
|
21 |
|
|
|
22 |
import java.util.Iterator; |
22 |
import org.netbeans.modules.masterfs.filebasedfs.FileBasedFileSystem; |
23 |
import org.netbeans.modules.masterfs.filebasedfs.FileBasedFileSystem; |
23 |
import org.netbeans.modules.masterfs.filebasedfs.Statistics; |
24 |
import org.netbeans.modules.masterfs.filebasedfs.Statistics; |
24 |
import org.netbeans.modules.masterfs.filebasedfs.children.ChildrenCache; |
25 |
import org.netbeans.modules.masterfs.filebasedfs.children.ChildrenCache; |
Lines 33-40
Link Here
|
33 |
|
34 |
|
34 |
import javax.swing.event.EventListenerList; |
35 |
import javax.swing.event.EventListenerList; |
35 |
import java.io.*; |
36 |
import java.io.*; |
|
|
37 |
import java.util.ArrayList; |
38 |
import java.util.Arrays; |
36 |
import java.util.Date; |
39 |
import java.util.Date; |
37 |
import java.util.Enumeration; |
40 |
import java.util.Enumeration; |
|
|
41 |
import java.util.List; |
38 |
import org.netbeans.modules.masterfs.providers.ProvidedExtensions; |
42 |
import org.netbeans.modules.masterfs.providers.ProvidedExtensions; |
39 |
import org.openide.util.Enumerations; |
43 |
import org.openide.util.Enumerations; |
40 |
|
44 |
|
Lines 154-168
Link Here
|
154 |
final String originalExt = getExt(); |
158 |
final String originalExt = getExt(); |
155 |
|
159 |
|
156 |
//TODO: no lock used |
160 |
//TODO: no lock used |
157 |
if (!NamingFactory.rename(getFileName(),file2Rename.getName(),handler)) { |
161 |
FileNaming[] allRenamed = NamingFactory.rename(getFileName(),file2Rename.getName(),handler); |
|
|
162 |
if (allRenamed == null) { |
158 |
FileObject parentFo = getExistingParent(); |
163 |
FileObject parentFo = getExistingParent(); |
159 |
String parentPath = (parentFo != null) ? parentFo.getPath() : file.getParentFile().getAbsolutePath(); |
164 |
String parentPath = (parentFo != null) ? parentFo.getPath() : file.getParentFile().getAbsolutePath(); |
160 |
FSException.io("EXC_CannotRename", file.getName(), parentPath, file2Rename.getName());// NOI18N |
165 |
FSException.io("EXC_CannotRename", file.getName(), parentPath, file2Rename.getName());// NOI18N |
161 |
} |
166 |
} |
162 |
|
|
|
163 |
FileBasedFileSystem fs = getLocalFileSystem(); |
167 |
FileBasedFileSystem fs = getLocalFileSystem(); |
164 |
fs.getFactory().rename(); |
168 |
fs.getFactory().rename(); |
165 |
BaseFileObj.attribs.renameAttributes(file.getAbsolutePath().replace('\\', '/'), file2Rename.getAbsolutePath().replace('\\', '/'));//NOI18N |
169 |
BaseFileObj.attribs.renameAttributes(file.getAbsolutePath().replace('\\', '/'), file2Rename.getAbsolutePath().replace('\\', '/'));//NOI18N |
|
|
170 |
for (int i = 0; i < allRenamed.length; i++) { |
171 |
FolderObj par = (allRenamed[i].getParent() != null) ? |
172 |
(FolderObj)fs.getFactory().get(allRenamed[i].getParent().getFile()) : null; |
173 |
if (par != null) { |
174 |
ChildrenCache childrenCache = par.getChildrenCache(); |
175 |
final Mutex.Privileged mutexPrivileged = (childrenCache != null) ? childrenCache.getMutexPrivileged() : null; |
176 |
if (mutexPrivileged != null) mutexPrivileged.enterWriteAccess(); |
177 |
try { |
178 |
childrenCache.removeChild(allRenamed[i].getName()); |
179 |
childrenCache.getChild(allRenamed[i].getName(), true); |
180 |
} finally { |
181 |
if (mutexPrivileged != null) mutexPrivileged.exitWriteAccess(); |
182 |
} |
183 |
} |
184 |
} |
185 |
|
166 |
fireFileRenamedEvent(originalName, originalExt); |
186 |
fireFileRenamedEvent(originalName, originalExt); |
167 |
} |
187 |
} |
168 |
|
188 |
|
Lines 353-360
Link Here
|
353 |
public final FileNaming getFileName() { |
373 |
public final FileNaming getFileName() { |
354 |
return fileName; |
374 |
return fileName; |
355 |
} |
375 |
} |
|
|
376 |
|
377 |
public final void delete(final FileLock lock) throws IOException { |
378 |
delete(lock, null); |
379 |
} |
356 |
|
380 |
|
357 |
public void delete(final FileLock lock) throws IOException { |
381 |
public void delete(final FileLock lock, ProvidedExtensions.DeleteHandler deleteHandler) throws IOException { |
358 |
final File f = getFileName().getFile(); |
382 |
final File f = getFileName().getFile(); |
359 |
|
383 |
|
360 |
final FolderObj existingParent = getExistingParent(); |
384 |
final FolderObj existingParent = getExistingParent(); |
Lines 367-379
Link Here
|
367 |
FSException.io("EXC_InvalidLock", lock, getPath()); // NOI18N |
391 |
FSException.io("EXC_InvalidLock", lock, getPath()); // NOI18N |
368 |
} |
392 |
} |
369 |
|
393 |
|
370 |
if (!f.delete()) { |
394 |
boolean deleteStatus = (deleteHandler != null) ? deleteHandler.delete(f) : f.delete(); |
|
|
395 |
if (!deleteStatus) { |
371 |
FileObject parent = getExistingParent(); |
396 |
FileObject parent = getExistingParent(); |
372 |
String parentPath = (parent != null) ? parent.getPath() : f.getParentFile().getAbsolutePath(); |
397 |
String parentPath = (parent != null) ? parent.getPath() : f.getParentFile().getAbsolutePath(); |
373 |
FSException.io("EXC_CannotDelete", f.getName(), parentPath);// NOI18N |
398 |
FSException.io("EXC_CannotDelete", f.getName(), parentPath);// NOI18N |
374 |
} |
399 |
} |
375 |
BaseFileObj.attribs.deleteAttributes(f.getAbsolutePath().replace('\\', '/'));//NOI18N |
400 |
BaseFileObj.attribs.deleteAttributes(f.getAbsolutePath().replace('\\', '/'));//NOI18N |
376 |
if (childrenCache != null) childrenCache.getChild(BaseFileObj.getNameExt(f), true); |
401 |
if (childrenCache != null) { |
|
|
402 |
if (deleteHandler != null) { |
403 |
childrenCache.removeChild(BaseFileObj.getNameExt(f)); |
404 |
} else { |
405 |
childrenCache.getChild(BaseFileObj.getNameExt(f), true); |
406 |
} |
407 |
} |
377 |
} finally { |
408 |
} finally { |
378 |
if (mutexPrivileged != null) mutexPrivileged.exitWriteAccess(); |
409 |
if (mutexPrivileged != null) mutexPrivileged.exitWriteAccess(); |
379 |
setValid(false); |
410 |
setValid(false); |
Lines 382-388
Link Here
|
382 |
fireFileDeletedEvent(false); |
413 |
fireFileDeletedEvent(false); |
383 |
|
414 |
|
384 |
} |
415 |
} |
385 |
|
416 |
|
386 |
abstract boolean checkLock(FileLock lock) throws IOException; |
417 |
abstract boolean checkLock(FileLock lock) throws IOException; |
387 |
|
418 |
|
388 |
public Object writeReplace() { |
419 |
public Object writeReplace() { |
Lines 392-397
Link Here
|
392 |
abstract protected void setValid(boolean valid); |
423 |
abstract protected void setValid(boolean valid); |
393 |
|
424 |
|
394 |
abstract public void refresh(final boolean expected, boolean fire); |
425 |
abstract public void refresh(final boolean expected, boolean fire); |
|
|
426 |
|
395 |
|
427 |
|
396 |
//TODO: attributes written by VCS must be readable by FileBaseFS and vice versa |
428 |
//TODO: attributes written by VCS must be readable by FileBaseFS and vice versa |
397 |
/** |
429 |
/** |