* InotifyNode --------------------------------------------------------------------------------------------------------- */
| 242 | * InotifyNode --------------------------------------------------------------------------------------------------------- |
| 243 | */ |
| 244 | InotifyTree::InotifyNode::InotifyNode( |
| 245 | InotifyTree *tree, |
| 246 | int inotifyInstance, |
| 247 | InotifyNode *parent, |
| 248 | const std::string &directory, |
| 249 | std::string name, |
| 250 | ino_t inodeNumber, |
| 251 | EmitCreatedEvent emitCreatedEvent |
| 252 | ): |
| 253 | mDirectory(directory), |
| 254 | mInodeNumber(inodeNumber), |
| 255 | mInotifyInstance(inotifyInstance), |
| 256 | mName(name), |
| 257 | mParent(parent), |
| 258 | mTree(tree) { |
| 259 | mChildren = new std::map<std::string, InotifyNode *>; |
| 260 | mFullPath = createFullPath(mDirectory, mName); |
| 261 | mWatchDescriptorInitialized = false; |
| 262 | |
| 263 | #ifdef NSFW_TEST_SLOW_1 |
| 264 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); |
| 265 | #endif |
| 266 | |
| 267 | if (!inotifyInit()) { |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | dirent ** directoryContents = NULL; |
| 272 | |
| 273 | int resultCountOrError = scandir( |
| 274 | mFullPath.c_str(), |
| 275 | &directoryContents, |
| 276 | NULL, |
| 277 | alphasort |
| 278 | ); |
| 279 | |
| 280 | mAlive = (resultCountOrError >= 0); |
| 281 | |
| 282 | if (!mAlive) { |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | for (int i = 0; i < resultCountOrError; ++i) { |
| 287 | std::string fileName = directoryContents[i]->d_name; |
| 288 | |
| 289 | if ( |
| 290 | fileName == "." || |
| 291 | fileName == ".." |
| 292 | ) { |
| 293 | continue; |
| 294 | } |
| 295 | |
| 296 | bool excludedFound = false; |
| 297 | for (std::string excludedPath : mTree->getExcludedPaths()) { |
| 298 | if ((mFullPath + '/' + fileName).compare(excludedPath) == 0) { |
| 299 | excludedFound = true; |
| 300 | break; |
| 301 | } |
nothing calls this directly
no test coverage detected