| 71 | } |
| 72 | |
| 73 | bool makeNonExecutable(const QString& path) { |
| 74 | struct stat fileStat{}; |
| 75 | |
| 76 | if (stat(path.toStdString().c_str(), &fileStat) != 0) { |
| 77 | std::cerr << "Failed to call stat() on " << path.toStdString() << std::endl; |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | auto permissions = fileStat.st_mode; |
| 82 | |
| 83 | // remove executable permissions |
| 84 | for (const auto permPart : {0100, 0010, 0001}) { |
| 85 | if (permissions & permPart) |
| 86 | permissions -= permPart; |
| 87 | } |
| 88 | |
| 89 | return chmod(path.toStdString().c_str(), permissions) == 0; |
| 90 | } |
| 91 | |
| 92 | QString expandTilde(QString path) { |
| 93 | if ((path.size() == 1 && path[0] == '~') || (path.size() >= 2 && path.startsWith("~/"))) { |