| 97 | } |
| 98 | |
| 99 | int main(int argc, char* argv[]) |
| 100 | { |
| 101 | std::vector<std::string> files; |
| 102 | std::string path; |
| 103 | int ch; |
| 104 | |
| 105 | while ((ch = getopt(argc, argv, "hf:d:")) > 0) |
| 106 | { |
| 107 | switch (ch) |
| 108 | { |
| 109 | case 'h': |
| 110 | usage(argv[0]); |
| 111 | return 0; |
| 112 | case 'f': |
| 113 | files.push_back(optarg); |
| 114 | break; |
| 115 | case 'd': |
| 116 | path = optarg; |
| 117 | break; |
| 118 | default: |
| 119 | break; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | char buf[1024]; |
| 124 | if (getcwd(buf, sizeof(buf)) == NULL) |
| 125 | { |
| 126 | printf("getcwd error %s\r\n", acl::last_serror()); |
| 127 | return 1; |
| 128 | } |
| 129 | |
| 130 | if (!path.empty()) |
| 131 | { |
| 132 | if (chdir(path.c_str()) < 0) |
| 133 | { |
| 134 | printf("chdir to %s error %s\r\n", path.c_str(), |
| 135 | acl::last_serror()); |
| 136 | return 1; |
| 137 | } |
| 138 | |
| 139 | scan_path(files); |
| 140 | } |
| 141 | |
| 142 | if (files.empty()) |
| 143 | { |
| 144 | usage(argv[0]); |
| 145 | return 1; |
| 146 | } |
| 147 | |
| 148 | create_files(files); |
| 149 | |
| 150 | // return the saved working path |
| 151 | if (chdir(buf) < 0) |
| 152 | { |
| 153 | printf("chdir to %s error %s\r\n", buf, acl::last_serror()); |
| 154 | return 1; |
| 155 | } |
| 156 | if(path.empty()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…