+2004-12-14 Angus Leeming <leeming@lyx.org>
+
+ * LaTeX.C: (startscript): use os::nulldev() rather than "/dev/null".
+
+ * bufferlist.C (emergencyWrite):
+ * lyx_main.C (queryUserLyXDir): use os::homepath(), not
+ GetEnvPath("HOME").
+
2004-12-14 Angus Leeming <leeming@lyx.org>
* main.C: (main): no longer pass pointers to os::init.
int LaTeX::startscript()
{
-#ifndef __EMX__
- string tmp = cmd + ' ' + QuoteName(file) + " > /dev/null";
-#else // cmd.exe (OS/2) causes SYS0003 error at "/dev/null"
- string tmp = cmd + ' ' + file + " > nul";
-#endif
+ string tmp = cmd + ' ' + QuoteName(file) + " > " + os::nulldev();
Systemcall one;
return one.startscript(Systemcall::Wait, tmp);
}
#include "frontends/Alert.h"
#include "support/filetools.h"
+#include "support/os.h"
#include <boost/bind.hpp>
using std::back_inserter;
using std::transform;
+namespace os = lyx::support::os;
BufferList::BufferList()
{}
}
// 2) In HOME directory.
- string s = AddName(GetEnvPath("HOME"), buf->fileName());
+ string s = AddName(os::homepath(), buf->fileName());
s += ".emergency";
lyxerr << ' ' << s << endl;
if (buf->writeFile(s)) {
+2004-12-14 Angus Leeming <leeming@lyx.org>
+
+ * FormFiledialog.C: (FileDlgCB): use os::homepath(), not
+ GetEnvPath("HOME").
+
2004-12-05 Angus Leeming <leeming@lyx.org>
* pch.h: s@<X11/forms.h>@"lyx_forms.h"@
#include "support/globbing.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
+#include "support/os.h"
#include "support/tostr.h"
#include "lyx_forms.h"
using std::vector;
using namespace lyx::frontend;
+namespace os = lyx::support::os;
namespace {
break;
case 11: // home
- current_dlg_->SetDirectory(GetEnvPath("HOME"));
+ current_dlg_->SetDirectory(os::homepath());
current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
current_dlg_->Reread();
break;
using lyx::support::os::getTmpDir;
using lyx::support::os::setTmpDir;
+namespace os = lyx::support::os;
+
using std::endl;
using std::string;
using std::vector;
if (!createDirectory(user_lyxdir(), 0755)) {
// Failed, let's use $HOME instead.
- user_lyxdir(GetEnvPath("HOME"));
+ user_lyxdir(os::homepath());
lyxerr << bformat(_("Failed. Will use %1$s instead."),
user_lyxdir()) << endl;
return;
+2004-12-14 Angus Leeming <leeming@lyx.org>
+
+ * os.h, os_os2.C, os_unix.C, os_win32.C:
+ (binpath, binname, getTmpDir): return a const reference rather than
+ a copy of the data.
+ (homepath, nulldev): new functions returning the name of "HOME" and
+ the null device, respectively.
+
+ * filetools.C: (ExpandPath, MakeDisplayPath):
+ * path_defines.C.in (setLyxPaths): use os::homepath(), not
+ GetEnvPath("HOME").
+
2004-12-14 Angus Leeming <leeming@lyx.org>
* os.h, os_{os2,unix,win32}.C (init): change interface to no longer
return getcwd() + '/' + RTemp;
}
if (Temp == "~") {
- return GetEnvPath("HOME") + '/' + RTemp;
+ return os::homepath() + '/' + RTemp;
}
if (Temp == "..") {
return MakeAbsPath(copy);
{
string str = path;
- string const home(GetEnvPath("HOME"));
+ string const home(os::homepath());
// replace /home/blah with ~/
if (prefixIs(str, home))
// do some work just once
void init(int argc, char * argv[]);
// returns path of LyX binary
-std::string binpath();
+std::string const & binpath();
// returns name of LyX binary
-std::string binname();
+std::string const & binname();
//
void setTmpDir(std::string const & p);
//
-std::string getTmpDir();
+std::string const & getTmpDir();
+// Returns the user's home directory ($HOME in the unix world).
+std::string const & homepath();
+// Returns the name of the NULL device (/dev/null, null).
+std::string const & nulldev();
//
std::string current_root();
//
string binpath_;
string binname_;
string tmpdir_;
+string homepath_;
+string nulldev_;
+
os::shell_type shell_ = os::UNIX;
unsigned long cp_ = 0;
// CPList[1] == system default codepage, the rest are auxilary.
// Once cp_ is correctly set, you can call other routines.
cp_ = CPList[1];
+
+ tmpdir_ = "/tmp";
+ homepath_ = GetEnvPath("HOME");
+ nulldev_ = "null";
}
}
-string binpath()
+string const & binpath()
{
return binpath_;
}
-string binname()
+string const & binname()
{
return binname_;
}
}
-string getTmpDir()
+string const & getTmpDir()
{
return tmpdir_;
}
+string const & homepath()
+{
+ return homepath_;
+}
+
+
+string const & nulldev()
+{
+ return nulldev_;
+}
+
+
shell_type shell()
{
return shell_;
string binpath_;
string binname_;
string tmpdir_;
+string homepath_;
+string nulldev_;
}
if (suffixIs(tmp, "/.libs/"))
tmp.erase(tmp.length() - 6, string::npos);
binpath_ = tmp;
+
+ tmpdir_ = "/tmp";
+ homepath_ = GetEnvPath("HOME");
+ nulldev_ = "/dev/null";
}
}
-string binpath()
+string const & binpath()
{
return binpath_;
}
-string binname()
+string const & binname()
{
return binname_;
}
}
-string getTmpDir()
+string const & getTmpDir()
{
return tmpdir_;
}
+string const & homepath()
+{
+ return homepath_;
+}
+
+
+string const & nulldev()
+{
+ return nulldev_;
+}
+
+
shell_type shell()
{
return UNIX;
string binpath_;
string binname_;
string tmpdir_;
+string homepath_;
+string nulldev_;
}
if (suffixIs(tmp, "/.libs/"))
tmp.erase(tmp.length()-6, string::npos);
binpath_ = tmp;
+
+#ifdef __CYGWIN__
+ tmpdir_ = "/tmp";
+ homepath_ = GetEnvPath("HOME");
+ nulldev_ = "/dev/null";
+#else
+ tmpdir_ = string();
+ homepath_ = GetEnvPath("HOMEDRIVE") + GetEnvPath("HOMEPATH");
+ nulldev_ = "nul";
+#endif
}
}
+string const & homepath()
+{
+ return homepath_;
+}
+
+
+string const & nulldev()
+{
+ return nulldev_;
+}
+
+
shell_type shell()
{
+#ifdef __CYGWIN__
return UNIX;
+#else
+ return CMD_EXE;
+#endif
}
} // namespace os
// default behaviour
if (user_lyxdir_.empty())
if (inOSXBundle)
- user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+ user_lyxdir_ = AddPath(os::homepath(),
"Library/Preferences/LyX");
else
- user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+ user_lyxdir_ = AddPath(os::homepath(),
string(".") + PACKAGE);
explicit_userdir = false;
}