fun toEncodeFileContent()

in intellij-plugin/educational-core/src/com/jetbrains/edu/learning/openApiExt.kt [86:106]


fun toEncodeFileContent(virtualFile: VirtualFile): Boolean {
  val path = virtualFile.path
  val name = PathUtil.getFileName(path)
  val extension = FileUtilRt.getExtension(name)
  if (isUnitTestMode && extension == EDU_TEST_BIN) {
    return true
  }
  val fileType = FileTypeManagerEx.getInstance().getFileTypeByFile(virtualFile)
  if (fileType !is UnknownFileType && fileType !is DetectedByContentFileType) {
    return fileType.isBinary
  }
  if (fileType is DetectedByContentFileType && extension == "db") {
    /** We do encode *.db files when sending them to Stepik. When we get them back they have [DetectedByContentFileType] fileType and by
     * default this file type is not binary, so we have to forcely specify it as binary
     */
    return true
  }
  // Files.probeContentType does not recognize mime font types on windows, so we check for font files separately
  val contentType = mimeFileType(path) ?: return isGitObject(name) || isFontExtension(extension)
  return isBinary(contentType)
}