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 |
|
43 |
|
40 |
/** |
44 |
/** |
Lines 188-202
Link Here
|
188 |
final String originalExt = getExt(); |
192 |
final String originalExt = getExt(); |
189 |
|
193 |
|
190 |
//TODO: no lock used |
194 |
//TODO: no lock used |
191 |
if (!NamingFactory.rename(getFileName(),file2Rename.getName(),handler)) { |
195 |
FileNaming[] allRenamed = NamingFactory.rename(getFileName(),file2Rename.getName(),handler); |
|
|
196 |
if (allRenamed == null) { |
192 |
FileObject parentFo = getExistingParent(); |
197 |
FileObject parentFo = getExistingParent(); |
193 |
String parentPath = (parentFo != null) ? parentFo.getPath() : file.getParentFile().getAbsolutePath(); |
198 |
String parentPath = (parentFo != null) ? parentFo.getPath() : file.getParentFile().getAbsolutePath(); |
194 |
FSException.io("EXC_CannotRename", file.getName(), parentPath, file2Rename.getName());// NOI18N |
199 |
FSException.io("EXC_CannotRename", file.getName(), parentPath, file2Rename.getName());// NOI18N |
195 |
} |
200 |
} |
196 |
|
|
|
197 |
FileBasedFileSystem fs = getLocalFileSystem(); |
201 |
FileBasedFileSystem fs = getLocalFileSystem(); |
198 |
fs.getFactory().rename(); |
202 |
fs.getFactory().rename(); |
199 |
BaseFileObj.attribs.renameAttributes(file.getAbsolutePath().replace('\\', '/'), file2Rename.getAbsolutePath().replace('\\', '/'));//NOI18N |
203 |
BaseFileObj.attribs.renameAttributes(file.getAbsolutePath().replace('\\', '/'), file2Rename.getAbsolutePath().replace('\\', '/'));//NOI18N |
|
|
204 |
for (int i = 0; i < allRenamed.length; i++) { |
205 |
FolderObj par = (allRenamed[i].getParent() != null) ? |
206 |
(FolderObj)fs.getFactory().get(allRenamed[i].getParent().getFile()) : null; |
207 |
if (par != null) { |
208 |
ChildrenCache childrenCache = par.getChildrenCache(); |
209 |
final Mutex.Privileged mutexPrivileged = (childrenCache != null) ? childrenCache.getMutexPrivileged() : null; |
210 |
if (mutexPrivileged != null) mutexPrivileged.enterWriteAccess(); |
211 |
try { |
212 |
childrenCache.removeChild(allRenamed[i].getName()); |
213 |
childrenCache.getChild(allRenamed[i].getName(), true); |
214 |
} finally { |
215 |
if (mutexPrivileged != null) mutexPrivileged.exitWriteAccess(); |
216 |
} |
217 |
} |
218 |
} |
219 |
|
200 |
fireFileRenamedEvent(originalName, originalExt); |
220 |
fireFileRenamedEvent(originalName, originalExt); |
201 |
} |
221 |
} |
202 |
|
222 |
|
Lines 384-391
Link Here
|
384 |
public final FileNaming getFileName() { |
404 |
public final FileNaming getFileName() { |
385 |
return fileName; |
405 |
return fileName; |
386 |
} |
406 |
} |
|
|
407 |
|
408 |
public final void delete(final FileLock lock) throws IOException { |
409 |
delete(lock, null); |
410 |
} |
387 |
|
411 |
|
388 |
public void delete(final FileLock lock) throws IOException { |
412 |
public void delete(final FileLock lock, ProvidedExtensions.DeleteHandler deleteHandler) throws IOException { |
389 |
final File f = getFileName().getFile(); |
413 |
final File f = getFileName().getFile(); |
390 |
|
414 |
|
391 |
final FolderObj existingParent = getExistingParent(); |
415 |
final FolderObj existingParent = getExistingParent(); |
Lines 398-410
Link Here
|
398 |
FSException.io("EXC_InvalidLock", lock, getPath()); // NOI18N |
422 |
FSException.io("EXC_InvalidLock", lock, getPath()); // NOI18N |
399 |
} |
423 |
} |
400 |
|
424 |
|
401 |
if (!f.delete()) { |
425 |
boolean deleteStatus = (deleteHandler != null) ? deleteHandler.delete(f) : f.delete(); |
|
|
426 |
if (!deleteStatus) { |
402 |
FileObject parent = getExistingParent(); |
427 |
FileObject parent = getExistingParent(); |
403 |
String parentPath = (parent != null) ? parent.getPath() : f.getParentFile().getAbsolutePath(); |
428 |
String parentPath = (parent != null) ? parent.getPath() : f.getParentFile().getAbsolutePath(); |
404 |
FSException.io("EXC_CannotDelete", f.getName(), parentPath);// NOI18N |
429 |
FSException.io("EXC_CannotDelete", f.getName(), parentPath);// NOI18N |
405 |
} |
430 |
} |
406 |
BaseFileObj.attribs.deleteAttributes(f.getAbsolutePath().replace('\\', '/'));//NOI18N |
431 |
BaseFileObj.attribs.deleteAttributes(f.getAbsolutePath().replace('\\', '/'));//NOI18N |
407 |
if (childrenCache != null) childrenCache.getChild(BaseFileObj.getNameExt(f), true); |
432 |
if (childrenCache != null) { |
|
|
433 |
if (deleteHandler != null) { |
434 |
childrenCache.removeChild(BaseFileObj.getNameExt(f)); |
435 |
} else { |
436 |
childrenCache.getChild(BaseFileObj.getNameExt(f), true); |
437 |
} |
438 |
} |
408 |
} finally { |
439 |
} finally { |
409 |
if (mutexPrivileged != null) mutexPrivileged.exitWriteAccess(); |
440 |
if (mutexPrivileged != null) mutexPrivileged.exitWriteAccess(); |
410 |
setValid(false); |
441 |
setValid(false); |
Lines 413-419
Link Here
|
413 |
fireFileDeletedEvent(false); |
444 |
fireFileDeletedEvent(false); |
414 |
|
445 |
|
415 |
} |
446 |
} |
416 |
|
447 |
|
417 |
abstract boolean checkLock(FileLock lock) throws IOException; |
448 |
abstract boolean checkLock(FileLock lock) throws IOException; |
418 |
|
449 |
|
419 |
public Object writeReplace() { |
450 |
public Object writeReplace() { |
Lines 423-428
Link Here
|
423 |
abstract protected void setValid(boolean valid); |
454 |
abstract protected void setValid(boolean valid); |
424 |
|
455 |
|
425 |
abstract public void refresh(final boolean expected, boolean fire); |
456 |
abstract public void refresh(final boolean expected, boolean fire); |
|
|
457 |
|
426 |
|
458 |
|
427 |
//TODO: attributes written by VCS must be readable by FileBaseFS and vice versa |
459 |
//TODO: attributes written by VCS must be readable by FileBaseFS and vice versa |
428 |
/** |
460 |
/** |