]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.C
small cleanup, doxygen, formatting changes
[lyx.git] / src / support / filetools.C
index 0c5393e518b596993c3c4fbadab899714c75de21..f843494cddcc75deede22d4f2d656a8840207772 100644 (file)
@@ -60,13 +60,6 @@ using std::endl;
 using std::ifstream;
 using std::vector;
 
-#if 0
-using std::getenv;
-using std::isalpha;
-using std::isalnum;
-using std::popen;
-#endif
-
 extern string system_lyxdir;
 extern string build_lyxdir;
 extern string user_lyxdir;
@@ -151,8 +144,10 @@ int IsFileWriteable (string const & path)
 //      -1: error- couldn't find out
 int IsDirWriteable (string const & path)
 {
-        string const tmpfl(lyx::tempName(path)); //TmpFileName(path));
-
+        string const tmpfl(lyx::tempName(path, "lyxwritetest"));
+       // We must unlink the tmpfl.
+       lyx::unlink(tmpfl);
+       
        if (tmpfl.empty()) {
                WriteFSAlert(_("LyX Internal Error!"), 
                             _("Could not test if directory is writeable"));
@@ -209,14 +204,14 @@ vector<string> const DirList(string const & dir, string const & ext)
 {
        // This is a non-error checking C/system implementation
        string extension(ext);
-       if (extension[0] != '.')
+       if (!extension.empty() && extension[0] != '.')
                extension.insert(0, ".");
        vector<string> dirlist;
        DIR * dirp = ::opendir(dir.c_str());
        dirent * dire;
        while ((dire = ::readdir(dirp))) {
                string const fil = dire->d_name;
-               if (prefixIs(fil, extension)) {
+               if (suffixIs(fil, extension)) {
                        dirlist.push_back(fil);
                }
        }
@@ -940,12 +935,9 @@ string const AddPath(string const & path, string const & path_2)
                        buf += '/';
        }
 
-       if (!path2.empty()) {
-               string::size_type const p2start = path2.find_first_not_of('/');
-               string::size_type const p2end = path2.find_last_not_of('/');
-               string const tmp = path2.substr(p2start, p2end - p2start + 1);
-               buf += tmp + '/';
-       }
+       if (!path2.empty())
+               buf += frontStrip(strip(path2, '/'), '/') + '/';
+
        return buf;
 }