*
* LyX, The Document Processor
*
- * Copyright (C) 1995 Matthias Ettrich
- * Copyright (C) 1995-1999 The LyX Team.
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef LYX_LIB_H
#define LYX_LIB_H
-#include <ctime>
-#include <unistd.h>
-
#include "LString.h"
-#include "gettext.h"
-#include "support/filetools.h"
-
-/// generates an checksum
-unsigned long lyxsum(char const * file);
-
-/// returns a date string
-inline char * date()
-{
- time_t tid;
- if ((tid= time(0)) == static_cast<time_t>(-1))
- return 0;
- else
- return ctime(&tid);
-}
-
// Where can I put this? I found the occurence of the same code
// three/four times. Don't you think it better to use a macro definition
// (an inlined member of some class)?
-///
-inline string getUserName()
-{
- string userName(GetEnv("LOGNAME"));
- if (userName.empty())
- userName = GetEnv("USER");
- if (userName.empty())
- userName = _("unknown");
- return userName;
-}
-// This should have been a namespace
-struct lyx {
- static char * getcwd(char * buffer, size_t size) {
-#ifndef __EMX__
- return ::getcwd(buffer, size);
+// Use a namespace if we can, a struct otherwise
+#ifdef CXX_WORKING_NAMESPACES
+#define OPT_STATIC
+namespace lyx {
#else
- return ::_getcwd2(buffer, size);
-#endif
- };
- static int chdir(char const * name) {
-#ifndef __EMX__
- return ::chdir(name);
+#define OPT_STATIC static
+struct lyx {
+#endif
+ ///
+ OPT_STATIC string const getcwd();
+ ///
+ OPT_STATIC int chdir(string const & name);
+ /// Returns false if it fails
+ OPT_STATIC bool rename(string const & from, string const & to);
+ /// Returns false it it fails
+ OPT_STATIC bool copy(string const & from, string const & to);
+ /// generates a checksum
+ OPT_STATIC unsigned long sum(string const & file);
+ /// returns a date string (not used currently)
+ OPT_STATIC char * date();
+ /// returns the name of the user (not used currently)
+ OPT_STATIC string const getUserName();
+ ///
+ OPT_STATIC int kill(int pid, int sig);
+ ///
+ OPT_STATIC void abort();
+ ///
+ OPT_STATIC int mkdir(string const & pathname, unsigned long int mode);
+ ///
+ OPT_STATIC int putenv(char const * str);
+ ///
+ OPT_STATIC int unlink(string const & file);
+ ///
+ OPT_STATIC int rmdir(string const & file);
+ ///
+ OPT_STATIC int atoi(string const & nstr);
+ ///
+ OPT_STATIC string const tempName(string const & dir = string(),
+ string const & mask = string());
+#ifdef CXX_WORKING_NAMESPACES
+}
#else
- return ::_chdir2(name);
-#endif
- };
};
#endif
+
+#undef OPT_STATIC
+
+#endif /* LYX_LIB_H */