def walk(top, func, arg): try: names = mac.listdir(top) except mac.error: return func(arg, top, names) for name in names: name = join(top, name) if isdir(name): walk(name, func, arg)
def glob1(dirname, pattern): if not dirname: dirname = ':' try: names = mac.listdir(dirname) except mac.error: return [] result = [] for name in names: if name[0] <> '.' or pattern[0] = '.': if fnmatch.fnmatch(name, pattern): result.append(name)
def packnotolder(outfp, dirname, oldest): names = mac.listdir(dirname) oldest = macpath.cat(dirname, oldest) st = mac.stat(oldest) mtime = st[ST_MTIME] todo = [] for name in names: print name, '...', st = mac.stat(macpath.cat(dirname, name)) if st[ST_MTIME] >= mtime: print 'Yes.' todo.append(name) else: print 'No.' todo.sort() packsome(outfp, dirname, todo)
def _stat(name): name = macpath.cat(cwd, name) if cache.has_key(name): return cache[name] if macpath.isfile(name): cache[name] = FILE return FILE try: list = mac.listdir(name) except: cache[name] = NONE return NONE cache[name] = list if name[-1:] = ':': cache[name[:-1]] = list else: cache[name+':'] = list return list
def lsdir(dirname): if not isdir(dirname): print dirname, ': no such directory' return names = mac.listdir(dirname) lsfiles(names, dirname)
def expandglobword(word): names = glob.globlist(mac.listdir(':'), word) if not names: raise glob_error, 'no match for pattern ' + word return names
def packall(outfp, dirname): names = mac.listdir(dirname) names.sort() packsome(outfp, dirname, names)