summaryrefslogtreecommitdiff
path: root/l10ntools/source/help
diff options
context:
space:
mode:
authorGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>2012-02-19 17:21:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-02-23 10:31:17 +0000
commitbc923636b45e47a4caeab6dff433aa28307ca145 (patch)
tree07f2a0bbd4335d1b8a6775b7c7d594e0620e902b /l10ntools/source/help
parent70a7cd0923795ee5c8210b476e2897d12988ad95 (diff)
HelpIndexer: use OSL for directory access
Diffstat (limited to 'l10ntools/source/help')
-rw-r--r--l10ntools/source/help/HelpIndexer.cxx38
1 files changed, 14 insertions, 24 deletions
diff --git a/l10ntools/source/help/HelpIndexer.cxx b/l10ntools/source/help/HelpIndexer.cxx
index 793348b2b2fa..a3ab752287a3 100644
--- a/l10ntools/source/help/HelpIndexer.cxx
+++ b/l10ntools/source/help/HelpIndexer.cxx
@@ -8,12 +8,7 @@
#endif
#include <rtl/string.hxx>
-
-#include <unistd.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
+#include <osl/file.hxx>
#include <algorithm>
@@ -77,27 +72,20 @@ bool HelpIndexer::scanForFiles() {
}
bool HelpIndexer::scanForFiles(rtl::OUString const & path) {
- rtl::OString pathStr;
- path.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0);
- DIR *dir = opendir(pathStr.getStr());
- if (dir == 0) {
- d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) + path +
- rtl::OUString::createFromAscii(strerror(errno));
+ osl::Directory dir(path);
+ if (osl::FileBase::E_None != dir.open()) {
+ d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) + path;
return true;
}
- struct dirent *ent;
- struct stat info;
- while ((ent = readdir(dir)) != 0) {
- rtl::OString entPath(pathStr);
- entPath += rtl::OString(RTL_CONSTASCII_STRINGPARAM("/")) + rtl::OString(ent->d_name);
- if (stat(entPath.getStr(), &info) == 0 && S_ISREG(info.st_mode)) {
- d_files.insert(rtl::OUString::createFromAscii(ent->d_name));
+ osl::DirectoryItem item;
+ osl::FileStatus fileStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Type);
+ while (dir.getNextItem(item) == osl::FileBase::E_None) {
+ if (fileStatus.getFileType() == osl::FileStatus::Regular) {
+ d_files.insert(fileStatus.getFileName());
}
}
- closedir(dir);
-
return true;
}
@@ -121,9 +109,11 @@ bool HelpIndexer::helpDocument(rtl::OUString const & fileName, Document *doc) {
}
lucene::util::Reader *HelpIndexer::helpFileReader(rtl::OUString const & path) {
- rtl::OString pathStr;
- path.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0);
- if (access(pathStr.getStr(), R_OK) == 0) {
+ osl::File file(path);
+ if (osl::FileBase::E_None == file.open(osl_File_OpenFlag_Read)) {
+ file.close();
+ rtl::OString pathStr;
+ path.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0); // FIXME: path encoding?
return new lucene::util::FileReader(pathStr.getStr(), "UTF-8");
} else {
return new lucene::util::StringReader(L"");