- struct dirent* dirent;
- struct stat statInfo;
- do {
- if ((dirent = readdir(pkgDir))) {
- std::string dirName = dirent->d_name;
- std::string absFileName = path + "/" + dirName;
- if (stat(absFileName.c_str(), &statInfo) != 0) {
- ThrowMsg(Exceptions::InternalError, "Error occurs read file");
- }
-
- if (S_ISDIR(statInfo.st_mode)) {
- if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
- "..") == 0) {
- continue;
- }
- EncryptDirectory(absFileName);
- } else {
- if (isSupportedForEncryption(absFileName)) {
- EncryptFile(absFileName);
+ while ((ftsent = fts_read(fts)) != NULL) {
+ switch (ftsent->fts_info) {
+ case FTS_DP:
+ case FTS_DC:
+ case FTS_D:
+ case FTS_DEFAULT:
+ case FTS_SLNONE:
+ //directories, non-regular files, dangling symbolic links
+ break;
+ case FTS_F:
+ case FTS_NSOK:
+ case FTS_SL:
+ //regular files and other objects that can be counted
+ if (isSupportedForEncryption(ftsent->fts_path)) {
+ EncryptFile(ftsent->fts_path);