getFileManager method

AbstractFileManager getFileManager (String filename, String currentDirectory, Contexts options, Environment environment, { bool isSync: false })

Returns the UrlFileManager or FileFileManager to load the filename

Implementation

AbstractFileManager getFileManager(String filename, String currentDirectory,
    Contexts options, Environment environment,
    {bool isSync = false}) {
  AbstractFileManager fileManager;

  if (filename == null) {
    logger.warn(
        'getFileManager called with no filename.. Please report this issue. continuing.');
  }

  if (currentDirectory == null) {
    logger.warn(
        'getFileManager called with null directory.. Please report this issue. continuing.');
  }

  if (fileManagers == null) {
    fileManagers = <AbstractFileManager>[
      //order is important
      FileFileManager(environment, PackageResolverProvider()),
      UrlFileManager(environment)
    ];
    if (options.pluginManager != null) {
      fileManagers.addAll(options.pluginManager.getFileManagers());
    }
  }

  for (int i = fileManagers.length - 1; i >= 0; i--) {
    fileManager = fileManagers[i];
    if (isSync &&
        fileManager.supportsSync(
            filename, currentDirectory, options, environment)) {
      return fileManager;
    }
    if (!isSync &&
        fileManager.supports(
            filename, currentDirectory, options, environment)) {
      return fileManager;
    }
  }
  return null;

//2.3.1
//  environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) {
//
//      if (!filename) {
//          logger.warn("getFileManager called with no filename.. Please report this issue. continuing.");
//      }
//      if (currentDirectory == null) {
//          logger.warn("getFileManager called with null directory.. Please report this issue. continuing.");
//      }
//
//      var fileManagers = this.fileManagers;
//      if (options.pluginManager) {
//          fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());
//      }
//      for(var i = fileManagers.length - 1; i >= 0 ; i--) {
//          var fileManager = fileManagers[i];
//          if (fileManager[isSync ? "supportsSync" : "supports"](filename, currentDirectory, options, environment)) {
//              return fileManager;
//          }
//      }
//      return null;
//  };
}