mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move getFile to StorageUtil to avoid dependency on DirectoryBasedStorage
This commit is contained in:
@@ -545,7 +545,7 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
|
||||
}
|
||||
|
||||
if (file == null) {
|
||||
file = DirectoryBasedStorage.getFile(fileName, dir, this)
|
||||
file = StorageUtil.getFile(fileName, dir, this)
|
||||
}
|
||||
|
||||
runWriteAction {
|
||||
|
||||
+2
-18
@@ -142,23 +142,7 @@ public class DirectoryBasedStorage extends StateStorageBase<DirectoryStorageData
|
||||
if (parentVirtualFile == null) {
|
||||
throw new StateStorageException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile));
|
||||
}
|
||||
return getFile(ioDir.getName(), parentVirtualFile, requestor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile getFile(@NotNull String fileName, @NotNull VirtualFile parent, @NotNull Object requestor) throws IOException {
|
||||
VirtualFile file = parent.findChild(fileName);
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
|
||||
AccessToken token = WriteAction.start();
|
||||
try {
|
||||
return parent.createChildData(requestor, fileName);
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
return StorageUtil.getFile(ioDir.getName(), parentVirtualFile, requestor);
|
||||
}
|
||||
|
||||
private static class MySaveSession extends SaveSessionBase {
|
||||
@@ -258,7 +242,7 @@ public class DirectoryBasedStorage extends StateStorageBase<DirectoryStorageData
|
||||
storeElement.setAttribute(StorageData.NAME, componentName);
|
||||
storeElement.addContent(element);
|
||||
|
||||
VirtualFile file = getFile(fileName, dir, MySaveSession.this);
|
||||
VirtualFile file = StorageUtil.getFile(fileName, dir, MySaveSession.this);
|
||||
StorageUtil.writeFile(null, MySaveSession.this, file, storeElement, LineSeparator.fromString(file.exists() ? StorageUtil.loadFile(file).second : SystemProperties.getLineSeparator()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+16
@@ -356,4 +356,20 @@ public class StorageUtil {
|
||||
public static boolean isProjectOrModuleFile(@NotNull String fileSpec) {
|
||||
return StoragePathMacros.PROJECT_FILE.equals(fileSpec) || fileSpec.startsWith(StoragePathMacros.PROJECT_CONFIG_DIR) || fileSpec.equals(StoragePathMacros.MODULE_FILE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile getFile(@NotNull String fileName, @NotNull VirtualFile parent, @NotNull Object requestor) throws IOException {
|
||||
VirtualFile file = parent.findChild(fileName);
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
|
||||
AccessToken token = WriteAction.start();
|
||||
try {
|
||||
return parent.createChildData(requestor, fileName);
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user