* commit 'ddb8e3b24b2fe3e4371ca8c1239748f5c71910f6': Fix to compile for windows
This commit is contained in:
@@ -9,8 +9,9 @@
|
|||||||
#include <utils/String8.h>
|
#include <utils/String8.h>
|
||||||
#include <utils/KeyedVector.h>
|
#include <utils/KeyedVector.h>
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "DirectoryWalker.h"
|
#include "DirectoryWalker.h"
|
||||||
#include "FileFinder.h"
|
#include "FileFinder.h"
|
||||||
@@ -21,6 +22,25 @@ using android::String8;
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
// Private function to check whether a file is a directory or not
|
||||||
|
bool isDirectory(const char* filename) {
|
||||||
|
struct stat fileStat;
|
||||||
|
if (stat(filename, &fileStat) == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return(S_ISDIR(fileStat.st_mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Private function to check whether a file is a regular file or not
|
||||||
|
bool isFile(const char* filename) {
|
||||||
|
struct stat fileStat;
|
||||||
|
if (stat(filename, &fileStat) == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return(S_ISREG(fileStat.st_mode));
|
||||||
|
}
|
||||||
|
|
||||||
bool SystemFileFinder::findFiles(String8 basePath, Vector<String8>& extensions,
|
bool SystemFileFinder::findFiles(String8 basePath, Vector<String8>& extensions,
|
||||||
KeyedVector<String8,time_t>& fileStore,
|
KeyedVector<String8,time_t>& fileStore,
|
||||||
DirectoryWalker* dw)
|
DirectoryWalker* dw)
|
||||||
@@ -45,14 +65,14 @@ bool SystemFileFinder::findFiles(String8 basePath, Vector<String8>& extensions,
|
|||||||
|
|
||||||
String8 fullPath = basePath.appendPathCopy(entryName);
|
String8 fullPath = basePath.appendPathCopy(entryName);
|
||||||
// If this entry is a directory we'll recurse into it
|
// If this entry is a directory we'll recurse into it
|
||||||
if (entry->d_type == DT_DIR) {
|
if (isDirectory(fullPath.string()) ) {
|
||||||
DirectoryWalker* copy = dw->clone();
|
DirectoryWalker* copy = dw->clone();
|
||||||
findFiles(fullPath, extensions, fileStore,copy);
|
findFiles(fullPath, extensions, fileStore,copy);
|
||||||
delete copy;
|
delete copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this entry is a file, we'll pass it over to checkAndAddFile
|
// If this entry is a file, we'll pass it over to checkAndAddFile
|
||||||
if (entry->d_type == DT_REG) {
|
if (isFile(fullPath.string()) ) {
|
||||||
checkAndAddFile(fullPath,dw->entryStats(),extensions,fileStore);
|
checkAndAddFile(fullPath,dw->entryStats(),extensions,fileStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,3 +110,4 @@ void SystemFileFinder::checkAndAddFile(String8 path, const struct stat* stats,
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
#endif //DEBUG
|
#endif //DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public:
|
|||||||
virtual bool findFiles(String8 basePath, Vector<String8>& extensions,
|
virtual bool findFiles(String8 basePath, Vector<String8>& extensions,
|
||||||
KeyedVector<String8,time_t>& fileStore,
|
KeyedVector<String8,time_t>& fileStore,
|
||||||
DirectoryWalker* dw) = 0;
|
DirectoryWalker* dw) = 0;
|
||||||
|
|
||||||
|
virtual ~FileFinder() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class SystemFileFinder : public FileFinder {
|
class SystemFileFinder : public FileFinder {
|
||||||
|
|||||||
Reference in New Issue
Block a user