isDataPath static method

bool isDataPath(
  1. String path
)

Check if a path is within the data directory (user-editable).

path - Relative path to check. Returns true if path is in geopod/data/ or is the data dir itself.

Implementation

static bool isDataPath(String path) {
  // Normalize: remove leading/trailing slashes.
  var normalized = path;
  if (normalized.startsWith('/')) {
    normalized = normalized.substring(1);
  }
  if (normalized.endsWith('/')) {
    normalized = normalized.substring(0, normalized.length - 1);
  }

  // Is it the data dir itself?

  if (normalized == dataDir || normalized == '$appDirName/$dataDir') {
    return true;
  }

  // Is it under data dir?
  return normalized.startsWith('$dataDir/') ||
      normalized.startsWith('$appDirName/$dataDir/');
}