Class SystemIgnoreHelper

java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.func.client.SystemIgnoreHelper

public final class SystemIgnoreHelper extends Object
Client-side guard, refuses to write (on sync) or send (on submit) files whose local path is protected, via two layers:
  1. Always-on — P4TRUST and P4TICKETS are blocked unconditionally, even when the adjustable map is cleared with $none.
  2. Adjustable map — the per-server P4_<PORT>_SYSTEMIGNORE variable, a ;-separated list. When unset/empty the built-in defaults apply ($defaults): .p4config, p4config.txt, .p4enviro, p4enviro.txt, and the resolved P4CONFIG/P4ENVIRO files.

Each entry is a literal path/filename or a token ($defaults, $none, $P4CONFIG, $P4ENVIRO, $home/~ — also a leading prefix), and may be prefixed with ! or - to unblock; entries evaluate in order, last match wins.

The value is read only from the environment (with a JVM system-property fallback for tests), never from a P4CONFIG file — a planted .p4config must not influence the map. The port-var name uppercases P4PORT and replaces every non-alphanumeric character with _, e.g. ssl:perforce.example.com:1666 → P4_SSL_PERFORCE_EXAMPLE_COM_1666_SYSTEMIGNORE.

  • Field Details

    • P4CONFIG_ENV_VAR

      public static final String P4CONFIG_ENV_VAR
      Name of the P4CONFIG environment variable (holds the config-file name).
      See Also:
    • P4ENVIRO_ENV_VAR

      public static final String P4ENVIRO_ENV_VAR
      Name of the P4ENVIRO environment variable (holds the enviro-file path).
      See Also:
    • SYSTEMIGNORE_ENV_PREFIX

      public static final String SYSTEMIGNORE_ENV_PREFIX
      Prefix for the per-server system-ignore environment variable.
      See Also:
    • SYSTEMIGNORE_ENV_SUFFIX

      public static final String SYSTEMIGNORE_ENV_SUFFIX
      Suffix for the per-server system-ignore environment variable.
      See Also:
  • Method Details

    • isProtected

      public static boolean isProtected(@Nonnull String path, @Nonnull RpcServer server, @Nullable RpcConnection rpcConnection)
      Returns true if the given local path is protected and must not be written or sent.
      Parameters:
      path - absolute local path to check
      server - connected RPC server
      rpcConnection - active RPC connection; may be null to skip the per-server environment-variable lookup (the built-in defaults still apply)
      Returns:
      true if the write/send should be blocked
    • buildSystemIgnoreEnvVarName

      public static String buildSystemIgnoreEnvVarName(@Nonnull RpcConnection rpcConnection)
      Returns the P4_<PORT>_SYSTEMIGNORE environment-variable name for the given connection. For example, localhost:1666 becomes P4_LOCALHOST_1666_SYSTEMIGNORE.
    • sanitizePortForEnvVar

      public static String sanitizePortForEnvVar(@Nonnull String portStr)
      Changes the port string to upper case and replaces every character that is not a letter or digit with an underscore. For example ssl:perforce.example.com:1666 becomes SSL_PERFORCE_EXAMPLE_COM_1666.
    • resolveP4ConfigFile

      @Nullable public static String resolveP4ConfigFile(@Nonnull RpcServer server)
      Walks up from the client root to find the P4CONFIG file. Returns null if the P4CONFIG environment variable is not set, the client root is unavailable, or no matching file is found in the directory tree.
    • resolveP4EnviroFile

      @Nonnull public static String resolveP4EnviroFile()
      Resolves the P4ENVIRO file path: the value of the P4ENVIRO environment variable, or the platform default (~/.p4enviro) when unset. Never returns null.