4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * A selection of useful system functions made
10 * \author Lars Gullik Bjønnes
12 * Full author contact details are available in file CREDITS.
24 /// get the current working directory
25 std::string const getcwd();
26 /// change to a directory, 0 is returned on success.
27 int chdir(std::string const & name);
29 * rename a file, returns false if it fails.
30 * It can handle renames across partitions.
32 bool rename(std::string const & from, std::string const & to);
33 /// copy a file, returns false it it fails
34 bool copy(std::string const & from, std::string const & to);
35 /// generates a checksum of a file
36 unsigned long sum(std::string const & file);
37 /// FIXME: some point to this hmm ?
38 int kill(int pid, int sig);
41 /// create the given directory with the given mode
42 int mkdir(std::string const & pathname, unsigned long int mode);
43 /// put variable=value as a C std::string into the environment
44 bool putenv(std::string const & varname, std::string const & value);
45 /// unlink the given file
46 int unlink(std::string const & file);
47 /// remove the given directory
48 int rmdir(std::string const & file);
49 /// convert the given string to an integer
50 int atoi(std::string const & nstr);
51 /// (securely) create a temporary file in the given dir with the given prefix
52 std::string const tempName(std::string const & dir = std::string(),
53 std::string const & mask = std::string());
57 * Returns true if var is approximately equal to number with allowed error
60 * Usage: if (float_equal(var, number, 0.0001)) { }
62 * This will check if 'var' is approx. equal to 'number' with error of 1/1000
64 inline bool float_equal(float var, float number, float error)
66 return (number - error <= var && var <= number + error);
69 } // namespace support
72 #endif /* LYX_LIB_H */