Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-113208

gameDir containing dots breaks some file opening methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • Minecraft 1.11.2, Minecraft 1.12
    • OS: Windows 7
    • Confirmed
    • (Unassigned)

      Based on 1.11.2 decompiled using MCP 9.35 rc1

      The bug

      Some file opening methods do not work when Minecraft is launched with a gameDir containing dots.

      Affected situations

      List might be incomplete
      Last updated for 1.11.2

      • opening screenshots (net.minecraft.util.ScreenShotHelper.saveScreenshot(File, String, int, int, Framebuffer))
      • opening crash reports
        • net.minecraft.client.Minecraft.displayCrashReport(CrashReport)
        • net.minecraft.server.MinecraftServer.run()
      • parts of realms (?) (net.minecraft.realms.Realms.getGameDirectoryPath())

      How to reproduce (old Java launcher)

      1. Create a profile with the following game directory
        ./game-data
        
      2. Start Minecraft with the profile
      3. Take a screenshot and try to open it by clicking on the message in chat
        → The file is not opened

      Additionally something like the following will appear in the Game Output of your launcher:

      20:02:05] [Client thread/ERROR]: Couldn't open link: Failed to open file:/LAUNCHER_PATH/./game-data/screenshots/2017-02-04_19.58.40.png. Error message: The system cannot find the file specified.
      

      Code analysis

      This happens because the affected methods call the method java.io.File.getAbsolutePath() for the screenshot file path which does not resolve dots. Instead the method java.io.File.getCanonicalPath() could be used.

            Unassigned Unassigned
            marcono1234 [Mod] Marcono1234
            Votes:
            3 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: