Browse Source

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
sbg
Beat Küng 8 years ago committed by Julian Oes
parent
commit
e061842219
  1. 50
      src/platforms/posix/main.cpp

50
src/platforms/posix/main.cpp

@ -358,12 +358,16 @@ int main(int argc, char **argv) @@ -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) @@ -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());
}
}
}

Loading…
Cancel
Save