#include <config.h>
+#include "support/filetools.h"
+
#include "support/convert.h"
+#include "support/debug.h"
#include "support/environment.h"
-#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/Package.h"
#include "support/Path.h"
#include "support/Systemcall.h"
+#include "support/qstring_helpers.h"
-// FIXME Interface violation
-#include "gettext.h"
-#include "debug.h"
+#include <QDir>
#include <boost/assert.hpp>
#include <boost/regex.hpp>
#include <fstream>
#include <sstream>
-using std::endl;
-using std::getline;
-using std::make_pair;
-using std::string;
-using std::ifstream;
-using std::ostringstream;
-using std::vector;
-using std::pair;
+using namespace std;
namespace lyx {
namespace support {
// Substitutes spaces with underscores in filename (and path)
-string const makeLatexName(string const & file)
+FileName const makeLatexName(FileName const & file)
{
- string name = onlyFilename(file);
- string const path = onlyPath(file);
+ string name = file.onlyFileName();
+ string const path = file.onlyPath().absFilename() + "/";
// ok so we scan through the string twice, but who cares.
+ // FIXME: in Unicode time this will break for sure! There is
+ // a non-latin world out there...
string const keep = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"@!'()*+,-./0123456789:;<=>?[]`|";
while ((pos = name.find_first_not_of(keep, pos)) != string::npos)
name[pos++] = '_';
- return addName(path, name);
+ FileName latex_name(path + name);
+ latex_name.changeExtension(".tex");
+ return latex_name;
}
variable. But we don't use the value if the currently
selected locale is the C locale. This is a GNU extension.
- Otherwise, w use a trick to guess what gettext has done:
+ Otherwise, w use a trick to guess what support/gettext.has done:
each po file is able to tell us its name. (JMarc)
*/
// stays unique. So we have to delete it before we can create
// a dir with the same name. Note also that we are not thread
// safe because of the gap between unlink and mkdir. (Lgb)
- unlink(tmpfl);
+ tmpfl.removeFile();
if (tmpfl.empty() || mkdir(tmpfl, 0700)) {
lyxerr << "LyX could not create the temporary directory '"
}
// returns absolute path
- return FileName(os::internal_path(tempBase));
+ return FileName(tempBase);
}
LYXERR(Debug::LATEX, "kpse status = " << c.first << '\n'
<< "kpse result = `" << rtrim(c.second, "\n\r") << '\'');
if (c.first != -1)
- return FileName(os::internal_path(rtrim(to_utf8(from_filesystem8bit(c.second)),
- "\n\r")));
+ return FileName(rtrim(to_utf8(from_filesystem8bit(c.second)), "\n\r"));
else
return FileName();
}
a += '#';
FileName const autosave(a);
if (autosave.exists())
- unlink(autosave);
+ autosave.removeFile();
}
LYXERR(Debug::GRAPHICS, "[readBB_from_PSFile] " << message);
// FIXME: Why is this func deleting a file? (Lgb)
if (zipped)
- unlink(file);
+ file.removeFile();
}
static boost::regex bbox_re(
"^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
- std::ifstream is(file_.toFilesystemEncoding().c_str());
+ ifstream is(file_.toFilesystemEncoding().c_str());
while (is) {
string s;
getline(is,s);
return cmp;
}
+
} //namespace support
} // namespace lyx