From e0618422197d4f9a98ebbaf36be2b928cde730bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 27 Sep 2016 10:29:07 +0200 Subject: [PATCH] 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 --- src/platforms/posix/main.cpp | 50 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index e36ff29091..68868a5596 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -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 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 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()); + } } }