+// ----------------------------------------------------------------------------
+// wrappers around standard POSIX functions
+// ----------------------------------------------------------------------------
+
+#if wxUSE_UNICODE && defined __BORLANDC__ \
+ && __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551
+
+// BCC 5.5 and 5.5.1 have a bug in _wopen where files are created read only
+// regardless of the mode parameter. This hack works around the problem by
+// setting the mode with _wchmod.
+//
+int wxCRT_Open(const wchar_t *pathname, int flags, mode_t mode)
+{
+ int moreflags = 0;
+
+ // we only want to fix the mode when the file is actually created, so
+ // when creating first try doing it O_EXCL so we can tell if the file
+ // was already there.
+ if ((flags & O_CREAT) && !(flags & O_EXCL) && (mode & wxS_IWUSR) != 0)
+ moreflags = O_EXCL;
+
+ int fd = _wopen(pathname, flags | moreflags, mode);
+
+ // the file was actually created and needs fixing
+ if (fd != -1 && (flags & O_CREAT) != 0 && (mode & wxS_IWUSR) != 0)
+ {
+ close(fd);
+ _wchmod(pathname, mode);
+ fd = _wopen(pathname, flags & ~(O_EXCL | O_CREAT));
+ }
+ // the open failed, but it may have been because the added O_EXCL stopped
+ // the opening of an existing file, so try again without.
+ else if (fd == -1 && moreflags != 0)
+ {
+ fd = _wopen(pathname, flags & ~O_CREAT);
+ }
+
+ return fd;
+}
+
+#endif
+
+// ----------------------------------------------------------------------------
+// wxPathList
+// ----------------------------------------------------------------------------
+
+bool wxPathList::Add(const wxString& path)
+{
+ // add a path separator to force wxFileName to interpret it always as a directory
+ // (i.e. if we are called with '/home/user' we want to consider it a folder and
+ // not, as wxFileName would consider, a filename).
+ wxFileName fn(path + wxFileName::GetPathSeparator());
+
+ // add only normalized relative/absolute paths
+ // NB: we won't do wxPATH_NORM_DOTS in order to avoid problems when trying to
+ // normalize paths which starts with ".." (which can be normalized only if
+ // we use also wxPATH_NORM_ABSOLUTE - which we don't want to use).
+ if (!fn.Normalize(wxPATH_NORM_TILDE|wxPATH_NORM_LONG|wxPATH_NORM_ENV_VARS))
+ return false;
+
+ wxString toadd = fn.GetPath();
+ if (Index(toadd) == wxNOT_FOUND)
+ wxArrayString::Add(toadd); // do not add duplicates
+
+ return true;
+}
+
+void wxPathList::Add(const wxArrayString &arr)