summaryrefslogtreecommitdiff
path: root/graphics/asymptote/locate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/asymptote/locate.cc')
-rw-r--r--graphics/asymptote/locate.cc31
1 files changed, 6 insertions, 25 deletions
diff --git a/graphics/asymptote/locate.cc b/graphics/asymptote/locate.cc
index d1c11a1f27..afea7272d0 100644
--- a/graphics/asymptote/locate.cc
+++ b/graphics/asymptote/locate.cc
@@ -5,14 +5,11 @@
* Locate files in search path.
*****/
-#include <unistd.h>
-
#include "settings.h"
#include "util.h"
#include "locate.h"
-
namespace settings {
namespace fs {
@@ -28,7 +25,7 @@ string extension(string name)
bool exists(string filename)
{
- return ::access(filename.c_str(), R_OK) == 0;
+ return fileExists(filename);
}
} // namespace fs
@@ -66,28 +63,14 @@ string locateFile(string id, bool full, string suffix)
{
if(id.empty()) return "";
file_list_t filenames = mungeFileName(id,suffix);
- for (file_list_t::iterator leaf = filenames.begin();
- leaf != filenames.end();
- ++leaf) {
-#ifdef __MSDOS__
- size_t p;
- while ((p=leaf->find('\\')) < string::npos)
- (*leaf)[p]='/';
- if ((p=leaf->find(':')) < string::npos && p > 0) {
- (*leaf)[p]='/';
- leaf->insert(0,"/cygdrive/");
- }
-#endif
-
- if ((*leaf)[0] == '/') {
- string file = *leaf;
+ for (auto const& leaf : filenames) {
+ if (leaf[0] == '/') { // FIXME: Add windows path check
+ string file = leaf;
if (fs::exists(file))
return file;
} else {
- for (file_list_t::iterator dir = searchPath.begin();
- dir != searchPath.end();
- ++dir) {
- string file = join(*dir,*leaf,full);
+ for (auto const& dir : searchPath) {
+ string file = join(dir,leaf,full);
if (fs::exists(file))
return file;
}
@@ -97,5 +80,3 @@ string locateFile(string id, bool full, string suffix)
}
} // namespace settings
-
-