Auto-rename failure with "5/27&qu...

kenji uno
2012-06-06
2013-05-08
  • kenji uno

    kenji uno - 2012-06-06

    Hi.

    I get an error message on extraction, when I select  for "5/27" directory.

    java.lang.StringIndexOutOfBoundsException: String index out of range: 4
      java.lang.String.charAt(Unknown Source)
      org.catacombae.hfsexplorer.FileNameTools.isReservedWindowsFilename(FileNameTools.java:187)
      ...
    

    FileNameTools.java around 182 lines:

        public static boolean isReservedWindowsFilename(String filename) {
            if(reservedWindowsFilenames == null)
                reservedWindowsFilenames = buildReservedWindowsFilenames();
            if(reservedWindowsFilenames.contains(filename))
                return true;
            if(filename.charAt(4) == '.' && reservedWindowsFilenames.contains(filename.substring(0, 4)))
                return true;
            if(filename.charAt(3) == '.' && reservedWindowsFilenames.contains(filename.substring(0, 3)))
                return true;
            return false;
        }
    

    Anyone fixed  that problem?

    Thanks, kenji uno

     
  • kenji uno

    kenji uno - 2012-06-06

    Hi.

    I had workaround like following:

        public static boolean isReservedWindowsFilename(String filename) {
            if(reservedWindowsFilenames == null)
                reservedWindowsFilenames = buildReservedWindowsFilenames();
            if(reservedWindowsFilenames.contains(filename))
                return true;
            if(filename.length() > 4 && filename.charAt(4) == '.' && reservedWindowsFilenames.contains(filename.substring(0, 4)))
                return true;
            if(filename.length() > 3 && filename.charAt(3) == '.' && reservedWindowsFilenames.contains(filename.substring(0, 3)))
                return true;
            return false;
        }
    

    Thanks, kenji uno

     
  • kenji uno

    kenji uno - 2012-06-06

    Hi.

    Windows 7 won't accept the folder name with trailing space characters.

    So, here is workaround at FileSystemBrowserWindow.java line 2171.
    A workaround:

                String dirName = originalDirName.replaceAll("[ ]+$", "");
    

    Original code:

                String dirName = originalDirName;
    

    Thanks.

     

Log in to post a comment.