summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/server2/file_system_util.py
blob: 0882564719713f847d67ed9cf0dd4e69922cf1bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import posixpath

def CreateURLsFromPaths(file_system, directory, urlprefix):
  '''Yields a tuple (url, prefix) for every file in |directory|, where the URL
  is given relative to |urlprefix|.
  '''
  for root, _, files in file_system.Walk(directory):
    for f in files:
      url = posixpath.join(urlprefix, root, f)
      yield url, posixpath.join(directory, root, f)