Skip to content
Snippets Groups Projects
Commit e0618422 authored by Beat Küng's avatar Beat Küng Committed by Julian Oes
Browse files

posix main: only try to generate symlinks if data path argument given

if not given, the dirs are either not needed (eg RPI) or assumed to
exist already
parent 98ac60e3
No related branches found
No related tags found
No related merge requests found
......@@ -358,12 +358,16 @@ int main(int argc, char **argv)
return -1;
}
bool symlinks_needed = true;
if (positional_arg_count == 1) { //data path is optional
commands_file = data_path;
data_path = ".";
symlinks_needed = false;
} else {
cout << "data path: " << data_path << endl;
}
cout << "data path: " << data_path << endl;
cout << "commands file: " << commands_file << endl;
if (commands_file.size() < 1) {
......@@ -377,32 +381,34 @@ int main(int argc, char **argv)
}
// create sym-links
vector<string> path_sym_links;
path_sym_links.push_back("ROMFS");
path_sym_links.push_back("posix-configs");
path_sym_links.push_back("test_data");
if (symlinks_needed) {
vector<string> path_sym_links;
path_sym_links.push_back("ROMFS");
path_sym_links.push_back("posix-configs");
path_sym_links.push_back("test_data");
for (int i = 0; i < path_sym_links.size(); i++) {
string path_sym_link = path_sym_links[i];
//cout << "path sym link: " << path_sym_link << endl;
string src_path = data_path + "/" + path_sym_link;
string dest_path = pwd() + "/" + path_sym_link;
for (int i = 0; i < path_sym_links.size(); i++) {
string path_sym_link = path_sym_links[i];
//cout << "path sym link: " << path_sym_link << endl;
string src_path = data_path + "/" + path_sym_link;
string dest_path = pwd() + "/" + path_sym_link;
PX4_DEBUG("Creating symlink %s -> %s", src_path.c_str(), dest_path.c_str());
PX4_DEBUG("Creating symlink %s -> %s", src_path.c_str(), dest_path.c_str());
if (dirExists(path_sym_link)) { continue; }
if (dirExists(path_sym_link)) { continue; }
// create sym-links
int ret = symlink(src_path.c_str(), dest_path.c_str());
// create sym-links
int ret = symlink(src_path.c_str(), dest_path.c_str());
if (ret != 0) {
PX4_ERR("Error creating symlink %s -> %s",
src_path.c_str(), dest_path.c_str());
return ret;
if (ret != 0) {
PX4_ERR("Error creating symlink %s -> %s",
src_path.c_str(), dest_path.c_str());
return ret;
} else {
PX4_DEBUG("Successfully created symlink %s -> %s",
src_path.c_str(), dest_path.c_str());
} else {
PX4_DEBUG("Successfully created symlink %s -> %s",
src_path.c_str(), dest_path.c_str());
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment