Last change
on this file since 9 was
9,
checked in by Jari Häkkinen, 17 years ago
|
Started work with reading file structure.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.1 KB
|
Line | |
---|
1 | // $Id: Directory.cc 9 2005-12-30 08:24:00Z jari $ |
---|
2 | |
---|
3 | #include "Directory.h" |
---|
4 | #include "Node.h" |
---|
5 | |
---|
6 | #include <iostream> |
---|
7 | #include <iterator> |
---|
8 | |
---|
9 | #include <errno.h> // Needed to check error state below. |
---|
10 | #include <dirent.h> |
---|
11 | |
---|
12 | namespace theplu{ |
---|
13 | namespace svnstat{ |
---|
14 | |
---|
15 | Directory::Directory(const std::string& path) |
---|
16 | : Node(path) |
---|
17 | { |
---|
18 | DIR* directory=opendir(path.c_str()); |
---|
19 | if (!directory) { |
---|
20 | // Jari, throw exception |
---|
21 | std::cerr << "ERROR: opendir() failed; terminating" << std::endl; |
---|
22 | exit(1); |
---|
23 | } |
---|
24 | struct dirent* entry; |
---|
25 | errno=0; |
---|
26 | std::vector<std::string> entries; |
---|
27 | while ((entry=readdir(directory))) |
---|
28 | entries.push_back(std::string(entry->d_name)); // Jari, push backing |
---|
29 | if (errno) { |
---|
30 | // Jari, throw exception |
---|
31 | std::cerr << "ERROR: readdir() failure; terminating" << std::endl; |
---|
32 | exit(1); |
---|
33 | } |
---|
34 | closedir(directory); |
---|
35 | |
---|
36 | copy(entries.begin(),entries.end(), |
---|
37 | std::ostream_iterator<std::string>(std::cout,"\n")); |
---|
38 | } |
---|
39 | |
---|
40 | bool Directory::parse(void) |
---|
41 | { |
---|
42 | // Jari, where is the include for for_each? |
---|
43 | for_each(nn_.begin(),nn_.end(), std::mem_fun(&Node::parse)); |
---|
44 | return true; |
---|
45 | } |
---|
46 | |
---|
47 | }} // end of namespace svnstat and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.