java.lang.Object
net.i2p.installer.FixWinPaths

public class FixWinPathsextends Object

Post-install fixup of the installed wrapper.config on Windows, run by the installer as Main fixwinpaths wrapper.config.

The wrapper resolves a path containing a forward slash as a UNIX-style path and silently logs elsewhere, so the forward slashes that the izpack <parsable> substitution leaves in the shipped wrapper.config have to become backslashes. Only the four literal substitutions commented in replace() are applied - the file is not reparsed and paths are not made absolute, because the wrapper already resolves relative paths against its working directory. Other forward slashes in the file are left alone, and are harmless only because the wrapper accepts a mixed-separator path. Usage: FixWinPaths wrapper.config
  • Constructor Details

    • FixWinPaths

      public FixWinPaths()
      Constructor. The rewrite is driven entirely by main() and the platform property, so an instance carries no state.
  • Method Details

    • main

      public static void main(String[] args)
      Rewrite the forward slashes in the given wrapper.config to backslashes. Does nothing unless os.name starts with "Win".
      Parameters:
      args - exactly one element, the path of the wrapper.config to fix
    • replace

      private static void replace(String file)
      Rewrite wrapper.config in place, via a sibling .tmp file. Exits 1 if the rewritten file cannot be put in place, and returns silently if the name is not a wrapper.config.

      Windows refuses a rename onto an existing file, so the original has to be removed before the temp file can take its name. That ordering makes a failed delete or rename destructive, so both are reported as failures rather than being allowed to look like success, and the temp file is verified before the original is touched.

      Parameters:
      file - path of the wrapper.config to rewrite
    • replaceFromTemp

      static boolean replaceFromTemp(String wConf, String wConfTemp)
      Put a fully written temp file in place of the original.

      Refuses to remove the original unless the temp file is present and non-empty, so a truncated or missing temp file cannot leave the install with no wrapper.config at all.

      Parameters:
      wConf - path of the original file
      wConfTemp - path of the rewritten sibling
      Returns:
      true if the temp file is now the original