Adds static files endpoint with optional directory index.
438468
def add(app, url = None, path = None, endpoint=None, decorate=None, index='index.html', **options):
    """"""

    url = url or app.static_url_path or ''
    path = os.path.abspath(path or app.static_folder or '.')
    endpoint = endpoint or 'static_' + os.path.basename(path)
    decorate = decorate or (lambda f: f)
    endpoints = {}

    if path == app.static_folder:
        raise ValueError('Files in `{}` path are already automatically served on `{}` URL by Flask.'
            ' Set Flask app static_folder to None, if you want to serve them using Flask Ecstatic at `{}` URL'
            .format(path, app.static_url_path, url))

    @app.route(url + '/<path:filename>', endpoint = endpoint)
    @handle404
    @decorate
    def static_files(filename):
        if index:
            filename = safe_join(path, filename)
            if os.path.isdir(filename):
                filename = os.path.join(filename, index)
            return send_file(filename, **options)
        else:
            return send_from_directory(path, filename, **options)

    endpoints[endpoint] = static_files

    if index:
         @app.route(url + '/', endpoint = endpoint + '_index')
         @handle404
         @decorate
         def static_index():
             return send_from_directory(path, index, **options)

         endpoints[endpoint + '_index'] = static_index

         if url:
             @app.route(url, endpoint = endpoint + '_index_bare')
             @handle404
             @decorate
             def static_index_bare():
                 return send_from_directory(path, index, **options)

             endpoints[endpoint + '_index_bare'] = static_index_bare

    return endpoints
813049
def serve_static(filename=None, prefix='', basedir=None):
    
    if not basedir:
        basedir = os.path.join(os.path.dirname(__file__), 'third_party')
    return send_from_directory(os.path.join(basedir, prefix), filename)
1152042
def static(self, uri, file_or_directory, pattern=r'/?.+',
               use_modified_since=True, use_content_range=False):
        '''
        '''
        static_register(self, uri, file_or_directory, pattern,
                        use_modified_since, use_content_range)
104088
def _AddParentDirectories(self, path):
    
    path_segments = self.file_system.SplitPath(path)
    for segment_index in range(len(path_segments)):
      parent_path = self.file_system.JoinPath(path_segments[:segment_index])
      file_entry = self.file_system.GetFileEntryByPath(parent_path)
      if file_entry and not file_entry.IsDirectory():
        raise ValueError(
            'Non-directory parent file entry: {0:s} already exists.'.format(
                parent_path))

    for segment_index in range(len(path_segments)):
      parent_path = self.file_system.JoinPath(path_segments[:segment_index])
      if not self.file_system.FileEntryExistsByPath(parent_path):
        self.file_system.AddFileEntry(
            parent_path, file_entry_type=definitions.FILE_ENTRY_TYPE_DIRECTORY)
1107511
def addList(self, source_id, dir_path, is_recurcive=False, timestamp_reception=None, training_metadata=[]):
        """"""
        if not path.isdir(dir_path):
            raise ValueError(dir_path + ' is not a directory')
        files_to_send = _get_files_from_dir(dir_path, is_recurcive)
        succeed_upload = {}
        failed_upload = {}
        for file_path in files_to_send:
            try:
                resp = self.add(source_id=source_id,
                    file_path=file_path, profile_reference="",
                    timestamp_reception=timestamp_reception, training_metadata=training_metadata)
                if resp['code'] != 200 and resp['code'] != 201:
                    failed_upload[file_path] = ValueError('Invalid response: ' + str(resp))
                else:
                    succeed_upload[file_path] = resp
            except BaseException as e:
                failed_upload[file_path] = e
        result = {
            'success': succeed_upload,
            'fail': failed_upload
        }
        return result
111719
def add_static(self, prefix: str, path: PathLike, *,
                   name: Optional[str]=None,
                   expect_handler: Optional[_ExpectHandler]=None,
                   chunk_size: int=256 * 1024,
                   show_index: bool=False, follow_symlinks: bool=False,
                   append_version: bool=False) -> AbstractResource:
        
        assert prefix.startswith('/')
        if prefix.endswith('/'):
            prefix = prefix[:-1]
        resource = StaticResource(prefix, path,
                                  name=name,
                                  expect_handler=expect_handler,
                                  chunk_size=chunk_size,
                                  show_index=show_index,
                                  follow_symlinks=follow_symlinks,
                                  append_version=append_version)
        self.register_resource(resource)
        return resource
702310
function newDirectoryApi(input, opts, cb) {
    var fd = new FormData(), files = [];
    var iterate = function(entries, path, resolve) {
      var promises = [];
      entries.forEach(function(entry) {
        promises.push(new Promise(function(resolve) {
          if ("getFilesAndDirectories" in entry) {
            entry.getFilesAndDirectories().then(function(entries) {
              iterate(entries, entry.path + "/", resolve);
            });
          } else {
            if (entry.name) {
              var p = (path + entry.name).replace(/^[/\\]/, "");
              fd.append(opts.name, entry, p);
              files.push(p);
            }
            resolve();
          }
        }));
      });
      Promise.all(promises).then(resolve);
    };
    input.getFilesAndDirectories().then(function(entries) {
      new Promise(function(resolve) {
        iterate(entries, "/", resolve);
      }).then(cb.bind(null, fd, files));
    });
  }
755421
function(connect, options) {
          return [
            require('connect-livereload')(),
            // Default middlewares
            // Serve static files.
            connect.static(options.base),
            // Make empty directories browsable.
            connect.directory(options.base)
          ];
        }
506597
def _add_path(dir_name, payload_info_list):
    """"""
    for payload_info_dict in payload_info_list:
        file_name = payload_info_dict['filename'] or payload_info_dict['pid']
        payload_info_dict['path'] = d1_common.utils.filesystem.gen_safe_path(
            dir_name, 'data', file_name
        )
554075
function addStaticRoute(routePath, targets) {
		if (!Object.isArray(targets)) {
			targets = [targets];
		}
		targets.forEach(function(target) {
			if (target)
				app.use(routePath, app.middleware.static(path.resolve(config.rootDir, target)));
		});
	}
775302
function addToPath(directory) {
  var srcs = process.env.PATH.split(delimiter);
  if (srcs.indexOf(directory) === -1) {
    srcs.unshift(directory);
    process.env.PATH = srcs.join(delimiter);
    debug('added `%s` to $PATH and its now `%s`',
      directory, process.env.PATH);
  }
}
1169314
static public List<String> listFilesInDirectory(MuleContext muleContext, String endpointName) {

        logger.info("List endpoint: {}", endpointName);

        FTPClient ftpClient = null;
        List<String> fileNames = new ArrayList<String>();

        try {
            ftpClient = getFtpClient(muleContext, endpointName);

            EndpointURI endpointURI = getImmutableEndpoint(muleContext, endpointName).getEndpointURI();
            String path = endpointURI.getPath();

            logger.info("List directory: {}", path);

            FTPFile[] ftpFiles = ftpClient.listFiles(path);
            logger.debug("Number of files and sub-folders found: {}", ftpFiles.length);

            for (FTPFile ftpFile : ftpFiles){
                if (ftpFile.getType() == FTPFile.FILE_TYPE) {
                    String filename = path + "/" + ftpFile.getName();
                    fileNames.add(filename);
                    logger.debug("Added file {}", filename);
                }
            }

            logger.debug("Found {} files in {}", fileNames.size(), path);

        } catch (Exception e) {
            if (logger.isErrorEnabled()) logger.error("Failed to list files in endpoint " + endpointName, e);
            throw new RuntimeException(e);

        } finally {
            if (ftpClient != null) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {}
            }
        }

        return fileNames;
    }
84437
def addJsonDirectory(self, directory, test=None):
    """"""

    for filename in os.listdir(directory):
      try:
        fullPath = os.path.join(directory, filename)
        if not test or test(filename, fullPath):
          with open(fullPath) as f:
            jsonData = json.load(f)
            name, _ = os.path.splitext(filename)
            self.addSource(name, jsonData)

      except ValueError:
        continue
663627
function addStaticAssetRoute(server, scaffold) {
        assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);

        const contentFolder = scaffold.folder || path.sep;
        const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
        const defaultAsset = scaffold.defaultAsset || 'index.html';
        const appendRequestPath = (scaffold.appendRequestPath  === false ? false : true); // default true

        // When we are running tests, the path to our assets will be different. 
        // We create the path using NODE_ENV which should be set to TESTING.
        let directory = path.join(__dirname, '..', '..', '..', '..', contentFolder);
        if ((process.env.NODE_ENV || '').toUpperCase() === 'TESTING') {
            directory = path.join(__dirname, "..", contentFolder);
        }
        debug(`Path ${scaffold.path} is serving static assets from ${directory}`);

        server.get(scaffold.path, serveStatic({
            directory,
            appendRequestPath,
            default: defaultAsset
        }));
    }
268797
def add(self, value):
        """"""
        path = value if isinstance(value, Path) else Path(str(value))
        if path and path != path.parent:
            destination = self
            for part in path.parts:
                destination = destination.setdefault(part, DirectoryTree())
983280
private void addSourceRoot (final File directory)
  {
    if (this.project != null)
    {
      getLog ().debug ("Adding compile source root: " + directory);
      this.project.addCompileSourceRoot (directory.getAbsolutePath ());
    }
  }
1135531
public MemoryFileAttributes addDir( EightyPath dir, Principals principals ) {

        if( content.get( dir ).isPresent() ) {
            throw new IllegalArgumentException( "path exists already" );
        }

        if( !dir.isAbsolute() || dir.getParent() == null ) {
            throw new IllegalArgumentException( "path not absolute or without parent" );
        }

        PathContent parentContent = content.getOrThrow( childGetParent( dir ),
                                                        () -> new IllegalArgumentException( "parent does not exist" ) );

        content.put( dir, PathContent.newDir( principals ) );
        parentContent.kids.add( dir );
        parentContent.attis.setLastModifiedTime();
        parentContent.attis.setLastAccessTime();
        return parentContent.attis;
    }