Package ghidra.util

Class NamingUtilities

java.lang.Object
ghidra.util.NamingUtilities

public final class NamingUtilities extends Object
Utility class with static methods for validating project file names.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Max length for a name.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    demangle(String mangledName)
    Performs the inverse of the mangle method.
    static char
    Deprecated.
    this method may be removed in a subsequent release due to limited use and applicability (project names and project file names have different naming restrictions).
    static boolean
    Performs a validity check on a mangled name
    static boolean
    Deprecated.
    method has been deprecated due to improper and widespread use.
    static boolean
    Tests whether the given string is a valid project name.
    static String
    mangle(String name)
    Returns a string such that all uppercase characters in the given string are replaced by the MANGLE_CHAR followed by the lowercase version of the character.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      Max length for a name.
      See Also:
  • Method Details

    • isValidName

      @Deprecated public static boolean isValidName(String name)
      Deprecated.
      method has been deprecated due to improper and widespread use. New methods include isValidProjectName(String) and LocalFileSystem.testValidName(String,boolean).
      Tests whether the given string is a valid. Rules:
      • All characters must be a letter, digit (0..9), period, hyphen, underscore or space
      • May not exceed a length of 60 characters
      Parameters:
      name - name to validate
      Returns:
      true if specified name is valid, else false
    • isValidProjectName

      public static boolean isValidProjectName(String name)
      Tests whether the given string is a valid project name. Rules:
      • Name may not start with period
      • All characters must be a letter, digit (0..9), period, hyphen, underscore or space
      • May not exceed a length of 60 characters
      Parameters:
      name - name to validate
      Returns:
      true if specified name is valid, else false
    • findInvalidChar

      @Deprecated public static char findInvalidChar(String name)
      Deprecated.
      this method may be removed in a subsequent release due to limited use and applicability (project names and project file names have different naming restrictions).
      Find the invalid character in the given name.

      This method should only be used with isValidName(String)} and not isValidProjectName(String)

      Parameters:
      name - the name with an invalid character
      Returns:
      the invalid character or 0 if no invalid character can be found
      See Also:
    • mangle

      public static String mangle(String name)
      Returns a string such that all uppercase characters in the given string are replaced by the MANGLE_CHAR followed by the lowercase version of the character. MANGLE_CHARs are replaced by 2 MANGLE_CHARs. This method is to get around the STUPID windows problem where filenames are not case sensitive. Under Windows, Foo.exe and foo.exe represent the same filename. To fix this we mangle names first such that Foo.exe becomes _foo.exe.
      Parameters:
      name - name string to be mangled
      Returns:
      mangled name
    • demangle

      public static String demangle(String mangledName)
      Performs the inverse of the mangle method. A string is returned such that all characters following a MANGLE_CHAR are converted to uppercase. Two MANGLE chars in a row are replace by a single MANGLE_CHAR.
      Parameters:
      mangledName - mangled name string
      Returns:
      demangle name
    • isValidMangledName

      public static boolean isValidMangledName(String name)
      Performs a validity check on a mangled name
      Parameters:
      name - mangled name
      Returns:
      true if name can be demangled else false