filenameOf method

  1. @deprecated
String filenameOf(
  1. String path
)

Returns the extension of the path. The extension is the part behind the last '.'. If the only '.' is at the top, the result is '' otherwise the the last part with '.'. deprecated: Use basename() from package path

Implementation

@deprecated
String filenameOf(String path) {
  var rc = '';
  final ix = path.lastIndexOf('.');
  final ixSlash = path.lastIndexOf(sep);
  if (ixSlash < 0) {
    if (ix <= 0) {
      rc = path;
    } else {
      rc = path.substring(0, ix);
    }
  } else {
    if (ix <= ixSlash + 1) {
      rc = path.substring(ixSlash + 1);
    } else if (ix > ixSlash + 1) {
      rc = path.substring(ixSlash + 1, ix);
    }
  }
  return rc;
}