Advertisement
JoshDreamland

Untitled

Aug 17th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1.   static bool ff_matches() {
  2.     return found.dwFileAttributes == FILE_ATTRIBUTE_NORMAL
  3.         || (ff_attribs ^ found.dwFileAttributes);
  4.   }
  5.  
  6.   string file_find_first(string name,int attributes)
  7.   {
  8.     if (current_find!=INVALID_HANDLE_VALUE) file_find_close();
  9.    
  10.     ff_attribs = attributes;
  11.     current_find = FindFirstFile(name.c_str(), &found);
  12.     return ff_matches() ? found.cFileName : file_find_next();
  13.   }
  14.  
  15.   string file_find_next()
  16.   {
  17.     if (current_find == INVALID_HANDLE_VALUE) return "";
  18.    
  19.     do {
  20.       if (!FindNextFile(current_find, &found)) {
  21.         current_find = INVALID_HANDLE_VALUE;
  22.         return "";
  23.       }
  24.     } while (!ff_matches());
  25.    
  26.     return found.cFileName;
  27.   }
  28.  
  29.   void file_find_close() {
  30.     if (current_find == INVALID_HANDLE_VALUE) return;
  31.  
  32.     FindClose(current_find);
  33.     current_find = INVALID_HANDLE_VALUE;
  34.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement