| 281 | } |
| 282 | |
| 283 | bool fileIsWritable(const std::string& path) |
| 284 | { |
| 285 | // Struct for stat results |
| 286 | struct stat info; |
| 287 | |
| 288 | // Use stat to get file info (return false if result non-zero to indicate failure) |
| 289 | if (stat(path.c_str(), &info) != 0) |
| 290 | return false; |
| 291 | |
| 292 | // If its a directory not file, return false |
| 293 | if (info.st_mode & S_IFDIR) |
| 294 | return false; |
| 295 | |
| 296 | // Return true if write flag is set |
| 297 | return (info.st_mode & S_IWRITE) != 0; |
| 298 | } |
| 299 | |
| 300 | bool fileIsReadable(const std::string& path) |
| 301 | { |