Skip to content

Udacity Data Structures and Algorithms Nanodegree Project_2, Problem_2

Notifications You must be signed in to change notification settings

Mcan45/File-Recursion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

File-Recursion

For this problem, the goal is to write code for finding all files under a directory (and all directories beneath it) that end with ".c"

Here is an example of a test directory listing, which can be downloaded here:

./testdir ./testdir/subdir1 ./testdir/subdir1/a.c ./testdir/subdir1/a.h ./testdir/subdir2 ./testdir/subdir2/.gitkeep ./testdir/subdir3 ./testdir/subdir3/subsubdir1 ./testdir/subdir3/subsubdir1/b.c ./testdir/subdir3/subsubdir1/b.h ./testdir/subdir4 ./testdir/subdir4/.gitkeep ./testdir/subdir5 ./testdir/subdir5/a.c ./testdir/subdir5/a.h ./testdir/t1.c ./testdir/t1.h Python's os module will be useful—in particular, you may want to use the following resources:

os.path.isdir(path)

os.path.isfile(path)

os.listdir(directory)

os.path.join(...)

Note: os.walk() is a handy Python method which can achieve this task very easily. However, for this problem you are not allowed to use os.walk().

Here is some code for the function to get you started:

def find_files(suffix, path): """ Find all files beneath path with file name suffix.

Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.

There are no limit to the depth of the subdirectories can be.

Args:
  suffix(str): suffix if the file name to be found
  path(str): path of the file system

Returns:
   a list of paths
"""
return None

Note: While testing the program you should unzip the testdir.zip on the same directory. Or you can use any of uncompressed folder on the same directory that you want to search.

About

Udacity Data Structures and Algorithms Nanodegree Project_2, Problem_2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages