| 52 | } |
| 53 | |
| 54 | bool makeExecutable(const QString& path) { |
| 55 | struct stat fileStat{}; |
| 56 | |
| 57 | if (stat(path.toStdString().c_str(), &fileStat) != 0) { |
| 58 | std::cerr << "Failed to call stat() on " << path.toStdString() << std::endl; |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | // no action required when file is executable already |
| 63 | // this could happen in scenarios when an AppImage is in a read-only location |
| 64 | if ((fileStat.st_uid == getuid() && fileStat.st_mode & 0100) || |
| 65 | (fileStat.st_gid == getgid() && fileStat.st_mode & 0010) || |
| 66 | (fileStat.st_mode & 0001)) { |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | return chmod(path.toStdString().c_str(), fileStat.st_mode | 0111) == 0; |
| 71 | } |
| 72 | |
| 73 | bool makeNonExecutable(const QString& path) { |
| 74 | struct stat fileStat{}; |
no test coverage detected