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 /// unlink the given file
44 int unlink(std::string const & file);
45 /// (securely) create a temporary file in the given dir with the given prefix
46 std::string const tempName(std::string const & dir = std::string(),
47 std::string const & mask = std::string());
51 * Returns true if var is approximately equal to number with allowed error
54 * Usage: if (float_equal(var, number, 0.0001)) { }
56 * This will check if 'var' is approx. equal to 'number' with error of 1/1000
58 inline bool float_equal(double var, double number, double error)
60 return (number - error <= var && var <= number + error);
63 } // namespace support
66 #endif /* LYX_LIB_H */