本文整理匯總了Java中com.intellij.openapi.util.io.FileUtil.deleteWithRenaming方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.deleteWithRenaming方法的具體用法?Java FileUtil.deleteWithRenaming怎麽用?Java FileUtil.deleteWithRenaming使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.deleteWithRenaming方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerIndexer
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
/**
* @return true if registered index requires full rebuild for some reason, e.g. is just created or corrupted
*/
private <K, V> boolean registerIndexer(@NotNull final FileBasedIndexExtension<K, V> extension) throws IOException {
final ID<K, V> name = extension.getName();
final int version = extension.getVersion();
final File versionFile = IndexInfrastructure.getVersionFile(name);
final boolean versionFileExisted = versionFile.exists();
boolean versionChanged = false;
if (IndexingStamp.versionDiffers(versionFile, version)) {
if (versionFileExisted) {
versionChanged = true;
LOG.info("Version has changed for index " + name + ". The index will be rebuilt.");
}
if (extension.hasSnapshotMapping() && versionChanged) {
FileUtil.deleteWithRenaming(IndexInfrastructure.getPersistentIndexRootDir(name));
}
File rootDir = IndexInfrastructure.getIndexRootDir(name);
if (versionFileExisted) FileUtil.deleteWithRenaming(rootDir);
IndexingStamp.rewriteVersion(versionFile, version);
}
initIndexStorage(extension, version, versionFile);
return versionChanged;
}
示例2: dropUnregisteredIndices
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private void dropUnregisteredIndices() {
final Set<String> indicesToDrop = readRegisteredIndexNames();
for (ID<?, ?> key : myIndices.keySet()) {
indicesToDrop.remove(key.toString());
}
for (String s : indicesToDrop) {
FileUtil.deleteWithRenaming(IndexInfrastructure.getIndexRootDir(ID.create(s)));
}
}
示例3: buildStarted
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
public void buildStarted(CompileContext context) {
if (myForStubs) {
File stubRoot = getStubRoot(context);
if (stubRoot.exists() && !FileUtil.deleteWithRenaming(stubRoot)) {
context.processMessage(new CompilerMessage(myBuilderName, BuildMessage.Kind.ERROR, "External make cannot clean " + stubRoot.getPath()));
}
}
}
示例4: getStubGenerationOutputs
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static Map<ModuleBuildTarget, String> getStubGenerationOutputs(ModuleChunk chunk, CompileContext context) throws IOException {
Map<ModuleBuildTarget, String> generationOutputs = new HashMap<ModuleBuildTarget, String>();
File commonRoot = getStubRoot(context);
for (ModuleBuildTarget target : chunk.getTargets()) {
File targetRoot = new File(commonRoot, target.getModule().getName() + File.separator + target.getTargetType().getTypeId());
if (targetRoot.exists() && !FileUtil.deleteWithRenaming(targetRoot)) {
throw new IOException("External make cannot clean " + targetRoot.getPath());
}
if (!targetRoot.mkdirs()) {
throw new IOException("External make cannot create " + targetRoot.getPath());
}
generationOutputs.put(target, targetRoot.getPath());
}
return generationOutputs;
}
示例5: doInvalidation
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
protected void doInvalidation(Throwable e) {
FileUtil.deleteWithRenaming(myFile); // better alternatives ?
FSRecords.requestVfsRebuild(e);
}
示例6: onExceptionInstantiatingIndex
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void onExceptionInstantiatingIndex(int version, File versionFile, File indexRootDir, Exception e) throws IOException {
LOG.info(e);
FileUtil.deleteWithRenaming(indexRootDir);
IndexingStamp.rewriteVersion(versionFile, version); // todo snapshots indices
}
示例7: initIndexStorage
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private <K, V> void initIndexStorage(@NotNull FileBasedIndexExtension<K, V> extension, int version, @NotNull File versionFile)
throws IOException {
MapIndexStorage<K, V> storage = null;
final ID<K, V> name = extension.getName();
boolean contentHashesEnumeratorOk = false;
for (int attempt = 0; attempt < 2; attempt++) {
try {
if (extension.hasSnapshotMapping()) {
ContentHashesSupport.initContentHashesEnumerator();
contentHashesEnumeratorOk = true;
}
storage = new MapIndexStorage<K, V>(
IndexInfrastructure.getStorageFile(name),
extension.getKeyDescriptor(),
extension.getValueExternalizer(),
extension.getCacheSize(),
extension.keyIsUniqueForIndexedFile(),
extension.traceKeyHashToVirtualFileMapping()
);
final MemoryIndexStorage<K, V> memStorage = new MemoryIndexStorage<K, V>(storage);
final UpdatableIndex<K, V, FileContent> index = createIndex(name, extension, memStorage);
final InputFilter inputFilter = extension.getInputFilter();
myIndices.put(name, new Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>(index, new IndexableFilesFilter(inputFilter)));
if (inputFilter instanceof FileTypeSpecificInputFilter) {
((FileTypeSpecificInputFilter)inputFilter).registerFileTypesUsedForIndexing(new Consumer<FileType>() {
final Set<FileType> addedTypes = new THashSet<FileType>();
@Override
public void consume(FileType type) {
if (type == null || !addedTypes.add(type)) {
return;
}
List<ID<?, ?>> ids = myFileType2IndicesWithFileTypeInfoMap.get(type);
if (ids == null) myFileType2IndicesWithFileTypeInfoMap.put(type, ids = new ArrayList<ID<?, ?>>(5));
ids.add(name);
}
});
}
else {
myIndicesWithoutFileTypeInfo.add(name);
}
myUnsavedDataUpdateTasks.put(name, new DocumentUpdateTask(name));
myIndexIdToVersionMap.put(name, version);
if (!extension.dependsOnFileContent()) {
if (extension.indexDirectories()) myIndicesForDirectories.add(name);
myNotRequiringContentIndices.add(name);
}
else {
myRequiringContentIndices.add(name);
}
if (extension instanceof PsiDependentIndex) myPsiDependentIndices.add(name);
myNoLimitCheckTypes.addAll(extension.getFileTypesWithSizeLimitNotApplicable());
break;
}
catch (Exception e) {
LOG.info(e);
boolean instantiatedStorage = storage != null;
try {
if (storage != null) storage.close();
storage = null;
}
catch (Exception ignored) {
}
FileUtil.deleteWithRenaming(IndexInfrastructure.getIndexRootDir(name));
if (extension.hasSnapshotMapping() && (!contentHashesEnumeratorOk || instantiatedStorage)) {
FileUtil.deleteWithRenaming(IndexInfrastructure.getPersistentIndexRootDir(name)); // todo there is possibility of corruption of storage and content hashes
}
IndexingStamp.rewriteVersion(versionFile, version);
}
}
}