VirtualFile (@NotNull String sourcePath, @NotNull String targetPath) { String testDataPath = getTestDataPath(); File sourceFile = new File(testDataPath, toSystemDependentName(sourcePath)); if (!sourceFile.exists()) { File candidate = new File(sourcePath); if (candidate.isAbsolute()) { sourceFile = candidate; if (FileUtil.pathsEqual(targetPath, sourcePath)) { Path testDataPathObj = Paths.get(testDataPath); Path targetPathObj = Paths.get(targetPath); if (targetPathObj.startsWith(testDataPathObj) && !targetPathObj.equals(testDataPathObj)) { targetPath = testDataPathObj.relativize(targetPathObj).toString(); } else { throw new IllegalArgumentException("Cannot guess target path for '" + sourcePath + "'; please specify explicitly"); } } } } targetPath = FileUtil.toSystemIndependentName(targetPath); VirtualFile targetFile = myTempDirFixture.getFile(targetPath); if (!sourceFile.exists() && targetFile != null && targetPath.equals(sourcePath)) { return targetFile; } assertFileEndsWithCaseSensitivePath(sourceFile); assertTrue("Cannot find source file: " + sourceFile + "; test data path: " + testDataPath+"; sourcePath: "+sourcePath, sourceFile.exists()); assertTrue("Not a file: " + sourceFile, sourceFile.isFile()); if (targetFile == null) { targetFile = myTempDirFixture.createFile(targetPath); VfsTestUtil.assertFilePathEndsWithCaseSensitivePath(targetFile, sourcePath); targetFile.putUserData(VfsTestUtil.TEST_DATA_FILE_PATH, sourceFile.getAbsolutePath()); } copyContent(sourceFile, targetFile); return targetFile; }